流畅的nhibernate查询,其中nullable为int

时间:2012-11-27 21:21:29

标签: c# nhibernate fluent-nhibernate fluent

我有一个类似这样的课程:

public class WorkEntity
{
    ... // other stuff here
    public virtual int? WorkTypeID { get; set; }
}

在我加入的查询中,我需要按WorkTypeID

过滤我的结果
query.Where(() => workEntity.WorkTypeID == filter.WorkTypeID.Value);

它不起作用,因为类型可以为空,我怎样才能使它工作?

1 个答案:

答案 0 :(得分:0)

query.Where(() => workEntity.WorkTypeID != null && workEntity.WorkTypeID.Value == filter.WorkTypeID.Value);
相关问题