查询NHibernate的未映射列

查询NHibernate的未映射列

本文介绍了查询NHibernate的未映射列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个映射到使用NHibernate表一类。的问题是,只有一些属性被映射到表中的列。因为我们使用显示器的唯一列映射,但是我不知道是否有什么办法可以查询反对在未映射到我的类属性表中的其他列,这是好的。

I have a class that is mapped to a table using NHibernate. The problem is that only some of the properties are mapped to columns in the table. This is fine because the only columns we use for display are mapped, however I was wondering if there is any way to query against other columns in the table that aren't mapped to properties in my class.

例如,我们有一个表有以下栏目:

For example we have a table with the following columns:

Customer
-----------
CustomerId
Name
DateCreated

和我们有一个对象

public class Customer
{
    public virtual int CustomerId {get;set;}
    public virtual string name {get;set;}
}

名称客户ID 但是映射 dateCreated会不是因为我们从来没有在任何地方显示出来。我们想查询客户表中的某一日期创建的客户。有没有办法做到这一点的没有映射 dateCreated会?同时最好将做到这一点使用标准的API。

and name and customerId are mapped however DateCreated is not because we never display it anywhere. We would like to query the Customer table for customers that were created by a certain date. Is there any way to do this without mapping the DateCreated? Also it would be preferable to do this using the criteria API.

推荐答案

Ayende Rahien发布描述指定文章接入=空操作在映射只指定查询的属性。请参见。我还没有尝试过这个自己。

Ayende Rahien posted an article which describes specifying access="noop" in the mapping to specify query-only properties. See NHibernate – query only properties. I have not tried this myself.

这篇关于查询NHibernate的未映射列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:51