2012-04-18 93 views
1

我:添加where子句,LINQ

var x = from os in dbLinq.vmesne_ures 
     where ((os._projekt_id).Equals(_cb_projekt_id)) 
     orderby os.projekt_name 
     group new { vm_oseba_id = os._oseba_id } by os._oseba_id into uniqueIds 
     select uniqueIds.FirstOrDefault(); 

它返回唯一的ID。是否可以将where子句添加到x?像

var y = x ... where os._oseba_id < 100 

我知道我可以做的地方((os._projekt_id).Equals(_cb_projekt_id) && where os._oseba_id < 100)或类似的。我正在寻找这个解决方案,如果我可以添加到x另一个where

回答

3

是的,你可以添加其他的where子句

var x = from os in dbLinq.vmesne_ures 
     where ((os._projekt_id).Equals(_cb_projekt_id)) 
     where os._oseba_id < 100 
     orderby os.projekt_name 
     group new { vm_oseba_id = os._oseba_id } by os._oseba_id into uniqueIds 
     select uniqueIds.FirstOrDefault(); 

2个何在和& &运营商之间的唯一区别是,两名代表被创建,但算法仍然是O(n)

+0

我可以添加直接给x?像'x.where' ...如果你知道我试着做 – Traktor 2012-04-18 08:08:48

+0

@Traktor你有建全的查询变种Y =从x其中....你为什么要那么做操作系统? – 2012-04-18 08:11:59

+1

类似于'var y = From i in x where i._oseba_id <100'? – Traktor 2012-04-18 08:12:20