0

In the Simple.Data examples, there is an example of 'Magic Casting':

// When you assign the dynamic record to a static type, any matching properties are auto-mapped.
var db = Database.Open();
Customer customer = db.Customers.FindByCustomerId(1);

Does Simple.Data also magically cast if there are multiple records returned? Something like this:

var db = Database.Open();
IEnumerable<Customer> customers = db.Customers.FindBySurname("Smith");

Obviously I have tried the above and it doesn't work ("Cannot implicitly convert type" from SimpleQuery to my concrete type). Any advice would be welcome.

DavidGouge
  • 4,583
  • 6
  • 34
  • 46

1 Answers1

3

FindBySurname returns a single record. If you use FindAllBySurname you'll get an enumerable, which should magic cast OK. (If for some reason it doesn't, you can call .Cast() on it.)

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