问题
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