DBContext Filtering

本文关键字:Filtering DBContext | 更新日期: 2023-09-27 18:12:23

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

我想过滤dbcontext中的内容,我该怎么做?谁来帮帮我

DBContext Filtering

try in this way

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

我假设你的details有一个名称为Property的属性,但你可以使用你的字段,例如.Where(elem=> elem.Name=='Peeter' && elem.Age > 30) //takes elements with Age > 30 and Name=Peter