我有一个我执行的存储过程 context.Database.SqlQuery<MyObject>("MyProc")
MyObject 有一个只读属性:
[NotMapped]
public bool IsSomething { get { return this.otherproperty == "something"; } }
Run Code Online (Sandbox Code Playgroud)
所以我得到错误:
System.IndexOutOfRangeException:IsSomething at System.Data.ProviderBase.FieldNameLookup.GetOrdinal etc
这是因为MyProc IsSomething在结果列中没有(我100%肯定这可能是原因).
不应该忽略它,因为它是[NotMapped]吗?我需要为其他东西设置SqlQuery吗?
为了让事情变得更加奇怪,我只在生产中看到它,从Stackify的日志中看,并且页面似乎正确加载而浏览器没有任何错误.