我收集了一些HierarchyNodeEntity值和集合祖先。 現在我想通過使用值db.HierarchyNodeEntities從theAncestors得到值。如何使用包含在LINQ中使用C#
這裏我使用包含來實現這一點。但它不工作。我想用這個包含作爲像運算符在SQL中。任何人都可以告訴我如何在此LINQ中使用Like。
在此先感謝。
這裏是代碼:
var q = from p in db.HierarchyNodeEntities
where theAncestors.Contains(p.HierarchyNodeEntity)
group p by p.PropertyKey
into prop
select
prop.OrderByDescending(p => p.LevelId).
FirstOrDefault();
var list = q.ToList();
你可以定義「它不工作」?你會得到一個異常或意外的結果等? – nemesv 2012-07-27 11:32:05
我在我的集閤中獲得「0」值,但是包含HierarchyNodeEntity的集合。 – SuryaKavitha 2012-07-27 11:36:10