Fluent nhibernate query where nullable int

こ雲淡風輕ζ 提交于 2020-01-05 07:17:08

问题


I have a class similar like this:

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

in my joined queryover I need to filter my results by WorkTypeID

query.Where(() => workEntity.WorkTypeID == filter.WorkTypeID.Value);

it doesn't work, because the type is nullable, how can I make it work?


回答1:


query.Where(() => workEntity.WorkTypeID != null && workEntity.WorkTypeID.Value == filter.WorkTypeID.Value);


来源:https://stackoverflow.com/questions/13593292/fluent-nhibernate-query-where-nullable-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!