【发布时间】:2017-01-16 06:38:21
【问题描述】:
我的查询有问题。在我的表格中,我有 2 个元素,Active 设置为 true。为了测试,我尝试只选择错误的元素(列表应该返回 0 个元素),但我总是得到 2 个元素。
领域类
public Guid OrderStatusId { get; set; }
public string Name { get; set; }
public bool Active { get; set; }
public string Description { get; set; }
SQL 元素
OrderStatusId = Guid.NewGuid(), Name = "xxx", Active = true, Description = "yyy"
OrderStatusId = Guid.NewGuid(), Name = "zzz", Active = true, Description = "xxx"
实体选择
public List<SlOrderStat> getDataFromSlOrderStat(string name, bool? activity)
{
activity = false;
using (var ctx = new ServisContex(conectionString))
{
var list = ctx.SlOrdersStats;
if (name != string.Empty)
list.Where(l => l.Name != name);
if (activity != null)
list.Where(l => l.Active == activity);
return list.ToList();
}
}
我做错了什么?
【问题讨论】:
标签: c# entity-framework