.net 选择一个新对象,包括一个where
选择新对象时,如何使用.net 选择一个新对象,包括一个where,.net,vb.net,linq,.net,Vb.net,Linq,选择新对象时,如何使用Where和Linq 以下是我所拥有的: From x In mydb.vw_TransactionsWithNames Select New datetransaction() With {.start = x.StartDate, .ends = x.EndDate} Where x.fkCommunity = c.PkCommunity And x.isCancelled = 0 但是在使用{.start=x.StartDate,.ends=x.EndDate}
Where
和Linq
以下是我所拥有的:
From x In mydb.vw_TransactionsWithNames
Select New datetransaction() With {.start = x.StartDate, .ends = x.EndDate}
Where x.fkCommunity = c.PkCommunity And x.isCancelled = 0
但是在使用{.start=x.StartDate,.ends=x.EndDate}的Select New datetransaction()后出现了一个错误
->名称“x”未声明或不在当前范围内
谢谢。通过说明所需类型使表达式具体化。Where子句位于Select语句之前。
查询
是一种匿名类型
,是结果的集合
Dim query = From x As {datatype here} In mydb.vw_TransactionsWithNames
Where x.fkCommunity = c.PkCommunity And x.isCancelled = 0
Select New With {.start = x.StartDate, .ends = x.EndDate}
首先使用where子句您还需要一个变量来接受表达式:
Dim query=From…