流利nhibernate查询哪里可空int [英] Fluent nhibernate query where nullable int

查看:116
本文介绍了流利nhibernate查询哪里可空int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public class WorkEntity 
{
... //其他的东西在这里
public virtual int? WorkTypeID {get;组; }
}

在我加入的查询中我需要通过WorkTypeID筛选我的结果

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

它不起作用,因为类型是可以为空的,我怎样才能使它工作? ()=> workEntity.WorkTypeID!= null&& amp;& amp; amp;& amp; amp; ; workEntity.WorkTypeID.Value == filter.WorkTypeID.Value);


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?

解决方案

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

这篇关于流利nhibernate查询哪里可空int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆