简体   繁体   English

DBContext过滤

[英]DBContext Filtering

if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedArea))
            {
                using (dbContext c = new dbContext(dbContext.ConnectionString))
                {
                    c.CreateIfNotExists();
                    c.LogDebug = true;
                    MainLongListSelector.ItemsSource = c.details.ToList();
                }
            }

I want to filter the contents in dbcontext and how do i do? 我想过滤dbcontext中的内容,该怎么办? someone help me 谁来帮帮我

try in this way 以这种方式尝试

MainLongListSelector.ItemsSource = c.details.Where(elem=> elem.Property==5).ToList();// returns elements with Property=5

I am assuming that your details has a property with name Property but you can use your fields eg .Where(elem=> elem.Name=='Peeter' && elem.Age > 30) //takes elements with Age > 30 and Name=Peter 我假设您的details具有名称为Property但是您可以使用字段。例如.Where(elem=> elem.Name=='Peeter' && elem.Age > 30) //takes elements with Age > 30 and Name=Peter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM