小编use*_*980的帖子

为什么,第一个query.ToList()工作,但第二个不起作用?

我的问题是ToLinq()方法:

我没有理解为什么第一个请求没有问题,但是第二个请求给我一个例外:

(LINQ to Entities中不支持LINQ表达式arrayIndex n的节点类型)

            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     == …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework tolist

6
推荐指数
1
解决办法
355
查看次数

标签 统计

c# ×1

entity-framework ×1

linq ×1

tolist ×1