2014-10-30 71 views
0

当我们选择一个新对象时,我们如何使用WhereLinq选择一个新对象,其中包括一个

以下是我有:

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 

但我有Select New datetransaction() With {.start = x.StartDate, .ends = x.EndDate}后的错误 - “X”要么不声明或不在当前范围

谢谢>名称。

+2

使用WHERE子句第一 – OneFineDay 2014-10-30 19:47:13

+1

你还需要一个变量来接受表达式:'昏暗的查询=从...' – OneFineDay 2014-10-30 19:48:39

回答

1

通过陈述预期的类型使表达式具体化。 Where子句在Select语句之前。 queryAnonymous Type,是结果的集合。

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} 
相关问题