相关疑难解决方法(0)

返回IEnumerable <T>与IQueryable <T>

返回IQueryable<T>IEnumerable<T>?有什么区别?

IQueryable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;

IEnumerable<Customer> custs = from c in db.Customers
where c.City == "<City>"
select c;
Run Code Online (Sandbox Code Playgroud)

两者都会延迟执行,何时应该优先于另一个?

c# linq ienumerable iqueryable linq-to-sql

1051
推荐指数
13
解决办法
22万
查看次数

AsEnumerable()对LINQ实体的影响是什么?

这里这里阅读问题让我对这种情况有所了解,似乎使用AsEnumerable是内存消耗.有没有更好的方法来实现这个LINQ以及现在的方式,数据是否可靠?

删除AsEnumerable导致"除了Contains运算符之外,本地序列不能用于查询运算符的LINQ to SQL实现".

var results = from p in pollcards.AsEnumerable()
                          join s in spoils.AsEnumerable() on new { Ocr = p.OCR, fileName = p.PrintFilename } equals new { Ocr = s.seq, fileName = s.inputFileName }
                          where p.Version == null
                          orderby s.fileOrdering, s.seq
                          select new ReportSpoilsEntity
                          {
                              seq = s.seq,
                              fileOrdering = s.fileOrdering,
                              inputFileName = s.inputFileName,
                              Ocr = p.OCR,
                              ElectorName = p.ElectorName
                          };
Run Code Online (Sandbox Code Playgroud)

c# linq entity enumerable

19
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×2

linq ×2

entity ×1

enumerable ×1

ienumerable ×1

iqueryable ×1

linq-to-sql ×1