Ela*_*nda 9 .net c# linq asp.net
我怎样才能重构这个LINQ以使其工作?
var a = (from app in mamDB.Apps where app.IsDeleted == false
select string.Format("{0}{1}",app.AppName,
app.AppsData.IsExperimental? " (exp)": string.Empty))
.ToArray();}
Run Code Online (Sandbox Code Playgroud)
我现在得到错误:
LINQ to Entities无法识别方法'System.String Format(System.String,System.Object,System.Object)'方法,并且此方法无法转换为商店表达式.
我无用地尝试过:
return (from app in mamDB.Apps where app.IsDeleted == false
select new string(app.AppName + (app.AppsData != null &&
app.AppsData.IsExperimental)? " (exp)": string.Empty)).ToArray();
Run Code Online (Sandbox Code Playgroud)
Mar*_*ell 17
你可以string.Format在LINQ-to-Objects中做后面的事情:
var a = (from app in mamDB.Apps where app.IsDeleted == false
select new {app.AppName, app.AppsData.IsExperimental})
.AsEnumerable()
.Select(row => string.Format("{0}{1}",
row.AppName, row.IsExperimental ? " (exp)" : "")).ToArray();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9516 次 |
| 最近记录: |