Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 选择一个新对象,包括一个where_.net_Vb.net_Linq - Fatal编程技术网

.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…