c# - 如何转换为 simple.data 中的 IEnumerable<Guid>?

标签 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>();

我得到了

Cannot implicitly convert type 'Simple.Data.SimpleRecord' to 'System.Guid'

我应该如何更改查询?

最佳答案

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

var db = Database.Open();
IEnumerable<Guid> recetas = db.Factura
    .All()
    .Where(db.Factura.ObraSocialPlan_id == obraSocialPlanId)
    .Select(db.Factura.Id)
    .ToScalarList<Guid>();

如果你想要偷懒,这样你就可以在没有实际运行查询的情况下将可枚举传递到某个地方,请在 GitHub 页面上提出问题:http://github.com/markrendle/Simple.Data/issues

谢谢。

关于c# - 如何转换为 simple.data 中的 IEnumerable<Guid>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11375196/

相关文章:

c# - PushSharp Apple - 收到的消息是意外的或格式错误

azure - Simple.Data 和 Sql Azure transient 故障处理

.net - 带有 Simple.Data 的 Mini-Profiler

.net - 我如何管理带有 Simple.Data 的 MongoDb 集合中不断变化的数据结构?

c# - 如何在 Simple.Data 中使用 sql 函数(合并或 isnull)

c# - .NET 中的 SVN 用于小型项目

c# - 使用 C#,如何关闭格式错误的 XML 标记?

c# - WPF SimpleCommand 可以使用泛型吗?

c# - AddServiceEndpoint 抛出键为空?

c# - Monotouch 使用哪种数据访问技术