Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以不';不能在Linq到NHibernate查询中工作_Linq_Nhibernate_Linq To Nhibernate_Startswith - Fatal编程技术网

以不';不能在Linq到NHibernate查询中工作

以不';不能在Linq到NHibernate查询中工作,linq,nhibernate,linq-to-nhibernate,startswith,Linq,Nhibernate,Linq To Nhibernate,Startswith,在我的存储库中,我有: public IQueryable<ICustomer> GetByAddress(string address) { return from c in GetSession().Linq<ICustomer>() where c.Address.StartsWith(address) select c; } 然而,每当我这样做 var customers = myRepository.GetB

在我的存储库中,我有:

public IQueryable<ICustomer> GetByAddress(string address)
{
    return from c in GetSession().Linq<ICustomer>()
           where c.Address.StartsWith(address)
           select c;
}
然而,每当我这样做

var customers = myRepository.GetByAddress("123 Main Street");
我得到一个NullReferenceException:

System.NullReferenceException未处理
Message=“对象引用未设置为对象的实例。”
Source=“NHibernate”
StackTrace:
在NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetEntityName(ICriteria subcriteria,String propertyName)
在NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumns(String propertyName,ICriteria subcriteria)
在NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumnsUsingProjection(ICriteria subcriteria,String propertyName)
剪断

我已经剪掉了异常的其余部分,因为它非常冗长,如果有帮助的话,我可以添加它

为什么这不起作用,而完全相同的查询除了

where c.Address == address
很好用

有什么想法吗

编辑

我正在使用FluentNHibernate(其中Id是GUID,地址是字符串):

公共类CustomerMap:ClassMap
{
公共工作地图()
{
Id(x=>x.Id);
剪
Map(x=>x.Address).Not.Nullable();
}
}

我可以确认这应该适用于2.x linq提供程序,我的项目中有带限制的.starts示例,可以转换为正确的SQL。你确定你使用的是nhcontrib linq提供程序的最新版本吗?我有版本2.1.2,我将删除我的引用,并删除dll,然后重新下载以确保我获得了最新的dll。您可以看到,它确实受到提供程序的支持:因此,它与您的使用有关…我可以确认,这应该适用于2.x linq提供程序,在我的项目中,我有一些.starts的示例,这些示例具有转换为正确SQL的限制。你确定你使用的是nhcontrib linq提供程序的最新版本吗?我有版本2.1.2,我将删除我的引用,删除dll,然后重新下载,以确保我得到了最新的dll。您可以看到,它确实受到了提供程序的支持:因此,它必须与您的使用有关。。。
where c.Address == address
public class CustomerMap: ClassMap<ICustomer>
{
    public JobMap()
    {
        Id(x => x.Id);
        ...snip...
        Map(x => x.Address).Not.Nullable();
    }
}