New Posts New Posts RSS Feed: WinRT, Code First - query with Count()
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

WinRT, Code First - query with Count()

 Post Reply Post Reply
Author
zbig View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Oct-2012
Posts: 28
Post Options Post Options   Quote zbig Quote  Post ReplyReply Direct Link To This Post Topic: WinRT, Code First - query with Count()
    Posted: 27-Jul-2013 at 2:10pm
Hi,

WinRT, DevForce 7.2, EF Code First.

I would like to retrieve the number of my entities (let say Users), but very simple query code with Count() extension gives compile error message 'cannot convert from 'int' to 'IdeaBlade.EntityModel.IEntityQuery':

var usersQuery = appTestEntityManager.Users.Count();
var result = await appTestEntityManager.ExecuteQueryAsync(usersQuery);

How to get a number of Users without retrieving the whole set of Users to the client?

Thanks in advance for any advice.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2013 at 9:32am
"Count" is a scalar query operator and will return the integer value, not a query. You can use the DevForce AsScalarAsync method to turn this into an actual query which can be awaited, eg:

var result = await appTestEntityManager.Users.AsScalarAsync().Count();

More information here - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/async-immediate-execution.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down