小编ehs*_*san的帖子

LINQ to Entities无法识别方法'System.Linq.IQueryable`

我想运行这个LINQ简单代码在LINQ中有记录号,但结果是错误的

var model = _db2.Persons.Select(
    (x, index) => new 
    {
        rn = index + 1,
        col1 = x.Id
    }).ToList();
Run Code Online (Sandbox Code Playgroud)

错误:

LINQ to Entities无法识别方法'System.Linq.IQueryable 1[<>f__AnonymousType22 [System.Int32,System.Int32]]选择[Person,<> f__AnonymousType2 2](System.Linq.IQueryable1 [MvcApplication27.Models.Person],System.Linq.Expressions.Expression 1[System.Func3 [ MvcApplication27.Models.Person,System.Int32,<> f__AnonymousType2`2 [System.Int32,System.Int32]]])'方法,并且此方法无法转换为商店表达式.

.net c# linq entity-framework

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

如何向剃刀助手添加参数

我想知道HTML助手怎么样写@Html.TextBoxFor(model => model.signature)data-id辅助性生产中的输入参数如下图所示.

<input type="text" name="signature"  data-id="No Signature" />
Run Code Online (Sandbox Code Playgroud)

注1:参数之类dataId的工作是htmlAttributes因为它是一个简单的变量.

注2:我知道扩展方法和使用属性 @{var attributes = new Dictionary<string, object>{{ "data-id", "No Signature" }};}

我觉得必须有更好的方法来解决这个问题.任何的想法...?

非常感谢.

html c# asp.net-mvc html-helper razor

5
推荐指数
1
解决办法
1774
查看次数

标签 统计

c# ×2

.net ×1

asp.net-mvc ×1

entity-framework ×1

html ×1

html-helper ×1

linq ×1

razor ×1