2014-10-30 68 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} 
相關問題