我有linq请求。
我需要在select中获取item.Title
。怎么做?
var list = (from item in answer.SubItems.OfType<TItemView>()
where item.SubItems != null
from ty in item.SubItems
select ty as TDealRequestView
into request
select new
{
itemTitle = item.Title,//item not visible
Title = request.Title,
}).ToList();
答案 0 :(得分:1)
您可以使用关键字:let
in order to initialize your value request.Title
let request = your treatment... (request is local variable of your query)
答案 1 :(得分:1)
现在无法检查,但请尝试:
String title;
var list = (from item in answer.SubItems.OfType<TItemView>()
where item.SubItems != null
let title=item.title
...
//now use title
答案 2 :(得分:1)
替换:
select ty as TDealRequestView
into request
使用:
let request = ty as TDealRequestView