Add & Create ODD behaviour

I am new to Entity Framework ORM and am confused with the below. I am confused that my count in MessageBox both after AddObject and CreateObject is same as before adding??? Is this some expected behavior with any ORM? Thanks a bunch in advance.

// Sample Code

MessageBox.Show("Count before assignment " + _ctxEntitiesHR.GROUPS.Count());

// Try Add
GROUPS newGroup = new GROUPS();
newGroup.GRP_ID = 187;
newGroup.GRP_NAME = "group with ID 187";


// Try Create 
var newGrp = _ctxEntitiesHR.GROUPS.CreateObject();
newGrp.GRP_ID = 189;
newGrp.GRP_NAME = "group with ID 189";

MessageBox.Show("Count after assignment " + _ctxEntitiesHR.GROUPS.Count());


Try calling context.SaveChanges() before requesting the count.

I suspect the Count() will always run a query on the database, while your newly added item hasn't been saved yet.

Need Your Help

Fancybox using multiple galleries on same page

javascript jquery html css fancybox-2

I have a current Fancybox set up to display a youtube video or a gallery slideshow. Each is initiated by clicking on a play button (html object) containing the following links:

Get a list of users on a Google Apps domain

google-admin-sdk google-apps-marketplace google-provisioning-api google-directory-api

We have an app in the Google Apps Marketplace (the new one, i.e. using OAuth2) which needs to get a list of users in the domain.