我想运行这个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__AnonymousType22](System.Linq.IQueryable1 [MvcApplication27.Models.Person],System.Linq.Expressions.Expression1[System.Func3 [ MvcApplication27.Models.Person,System.Int32,<> f__AnonymousType2`2 [System.Int32,System.Int32]]])'方法,并且此方法无法转换为商店表达式.
我想知道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" }};}
我觉得必须有更好的方法来解决这个问题.任何的想法...?
非常感谢.