Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.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
C# 我如何向IEnumerable施法<;Guid>;用简单的数据?_C#_Simple.data - Fatal编程技术网

C# 我如何向IEnumerable施法<;Guid>;用简单的数据?

C# 我如何向IEnumerable施法<;Guid>;用简单的数据?,c#,simple.data,C#,Simple.data,我在simple.data中有这个查询 var db = Database.Open(); IEnumerable<Guid> recetas = db.Factura .All() .Where(db.Factura.ObraSocialPlan_id == obraSocialPlanId) .Select(db.Factura.Id) .Cast<Guid>(); var db=Database.Open(); IEnumerabl

我在simple.data中有这个查询

var db = Database.Open();
IEnumerable<Guid> recetas = db.Factura
    .All()
    .Where(db.Factura.ObraSocialPlan_id == obraSocialPlanId)
    .Select(db.Factura.Id)
    .Cast<Guid>();
var db=Database.Open();
IEnumerable recitas=db.Factura
.All()
.其中(db.Factura.ObraSocialPlan_id==ObraSocialPlan id)
.Select(db.Factura.Id)
.Cast();
我越来越

无法将类型
'Simple.Data.SimpleRecord'
隐式转换为
'System.Guid'


如何更改查询?

您不能对可枚举项执行此操作,但可以将其具体化为如下列表:

var db = Database.Open();
IEnumerable<Guid> recetas = db.Factura
    .All()
    .Where(db.Factura.ObraSocialPlan_id == obraSocialPlanId)
    .Select(db.Factura.Id)
    .ToScalarList<Guid>();
var db=Database.Open();
IEnumerable recitas=db.Factura
.All()
.其中(db.Factura.ObraSocialPlan_id==ObraSocialPlan id)
.Select(db.Factura.Id)
.ToScalarList();
如果您需要惰性,因此可以在没有实际运行查询的情况下将可枚举项传递到某个位置,请在GitHub页面上提出一个问题:


谢谢。

Sql数据类型是uniqueidentifier,它是一个Guid,是表Factura的主键。我的意思是在C代码中声明的db.Factura.Id是什么类型。.net类型是什么?我没有这方面的c代码,请参见标记的答案