vấn đề của tôi là với ToLinq) phương pháp (:Tại sao, query.ToList() đầu tiên làm việc, nhưng thứ hai không hoạt động?
Tôi không understind lý do tại sao công việc yêu cầu đầu tiên mà không có vấn đề, nhưng thứ hai cho tôi một ngoại lệ như:
(loại nút của biểu thức LINQ arrayIndex n không được hỗ trợ trong LINQ to Entities)
var q = from a in ctx.ImmImmobilisations select a;
q = q.Where(x => x.CodeEntite == "EDEF");
q = q.Where(x => x.CodeAffectation == "000001");
q = q.Where(x => x.Unite == "ITS");
q = q.OrderBy(x => x.CodeImmobilisation);
List<ImmImmobilisation> res = q.ToList();
var query = from e in ctx.ImmImmobilisations select e;
if (!string.IsNullOrEmpty(args[0])) query = query.Where(x => x.CodeEntite == args[0]);
if (!string.IsNullOrEmpty(args[1])) query = query.Where(x => x.CodeAffectation == args[1]);
if (!string.IsNullOrEmpty(args[2])) query = query.Where(x => x.CodeFamille == args[2]);
if (!string.IsNullOrEmpty(args[3])) query = query.Where(x => x.CodeCCout == args[3]);
if (!string.IsNullOrEmpty(unite)) query = query.Where(x => x.Unite == unite);
query = query.OrderBy(x => x.CodeImmobilisation);
var ress = query.ToList();