C# DBContext筛选
我想过滤dbcontext中的内容,我该怎么做? 有人帮帮我试试这个办法C# DBContext筛选,c#,windows-phone-8,visual-studio-2013,C#,Windows Phone 8,Visual Studio 2013,我想过滤dbcontext中的内容,我该怎么做? 有人帮帮我试试这个办法 if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedArea)) { using (dbContext c = new dbContext(dbContext.ConnectionString)) {
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedArea))
{
using (dbContext c = new dbContext(dbContext.ConnectionString))
{
c.CreateIfNotExists();
c.LogDebug = true;
MainLongListSelector.ItemsSource = c.details.ToList();
}
}
我假设您的详细信息有一个名为property的属性,但您可以使用您的字段,例如Whereelem=>elem.name=='Peeter'&&elem.Age>30//获取年龄>30且name=Peter的元素
MainLongListSelector.ItemsSource = c.details.Where(elem=> elem.Property==5).ToList();// returns elements with Property=5