nhibernate.linq简单(读哑)问题
我正试着绕着linq->nhib转 我有一个简单的sql,我正试图在nhibernate.linq中使用它nhibernate.linq简单(读哑)问题,linq,nhibernate,Linq,Nhibernate,我正试着绕着linq->nhib转 我有一个简单的sql,我正试图在nhibernate.linq中使用它 select * from ColModel where ColModel.DataIndex not in ('CostElement1', 'CostElement2', 'CostElement3') and ColModel.ReportId = 1 排除的数据索引值列表以名为excludeNames的列表的形式出现 以下是我尝试过的,但似乎并没有真正感受到爱: va
select * from
ColModel where ColModel.DataIndex
not in ('CostElement1', 'CostElement2', 'CostElement3')
and ColModel.ReportId = 1
排除的数据索引
值列表以名为excludeNames的列表
的形式出现
以下是我尝试过的,但似乎并没有真正感受到爱:
var s = base._sessionManager.OpenSession();
var query = from col in s.Linq<ColModel>()
where col.Report.Id == reportid &&
!(from c in s.Linq<ColModel>() select c.DataIndex).Contains(excludeNames)
select col;
return query.ToList();
var s=base.\u sessionManager.OpenSession();
var query=来自s.Linq()中的列
其中col.Report.Id==reportid&&
!(从s.Linq()中的c中选择c.DataIndex)
选择col;
返回query.ToList();
错误:
The type arguments for method 'System.Linq.Enumerable.Contains<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
无法从用法推断方法“System.Linq.Enumerable.Contains(System.Collections.Generic.IEnumerable,TSource)”的类型参数。尝试显式指定类型参数。
我很确定我是从偏移量开始写的,所以任何指针都会很感激:)
w://我想你的排除法是颠倒的
s = base._sessionManager.OpenSession();
var query = from col in s.Linq<ColModel>()
where col.Report.Id == reportid &&
!excludeNames.Contains(col.DataIndex)
select col;
return query.ToList();
s=base.\u sessionManager.OpenSession();
var query=来自s.Linq()中的列
其中col.Report.Id==reportid&&
!excludeNames.Contains(col.DataIndex)
选择col;
返回query.ToList();
Collection.Contains(item)将在(…Collection…
)中生成SQL项,添加否定将获得所需内容。Contains不接受列表
在LINQ中有解决这个问题的方法,但我不确定哪种方法(如果有的话)在NH LINQ中有效我不熟悉nhibernate中的LINQ,但Contains语句是否应该反过来?否则,您不检查单个数据索引是否包含它们的列表吗?