3

I have this query in simple.data

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

And I'm getting

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

How should I change the query?

casperOne
  • 73,706
  • 19
  • 184
  • 253
Rodrigo Juarez
  • 1,745
  • 1
  • 23
  • 38

1 Answers1

8

You can't do this to an enumerable, but you can materialise it to a list like this:

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

If you want laziness, so you can pass the enumerable somewhere without having actually run the query, please raise an issue on the GitHub page: http://github.com/markrendle/Simple.Data/issues

Thanks.

Mark Rendle
  • 9,274
  • 1
  • 32
  • 58