mardi 23 février 2016

Unable to convert EntityFramework Raw Query into single integer result

Can anyone please tell me how to convert an Entity Framework Raw Query into a single integer result for a SELECT COUNT(*) query?

I have my query (that if run manually in the database) returns a valid result. However, I can't seem to work out how to return it as an integer value without compile errors:

var result = _context.Tickets.FromSql(query);
int count = result.FirstOrDefault(); <== Throws an error
return count;

The error I'm getting is Cannot implicitly convert type 'SpiceWire.Models.Tickets' to 'int'

Aucun commentaire:

Enregistrer un commentaire