locked
Bug with TryGetEntity<TEntity> RRS feed

  • Question

  • The following is my code segment:

    Uri serviceUri = new Uri(@"http://localhost:1230/WebDataServiceTest.svc/");

    NORTHWINDEntities serContext = new NORTHWINDEntities(this.serviceUri);

                Customers customerTest = null;
                Uri custUri = new Uri(serContext.BaseUri + "Customers('ALFKI')");

                //var alfki = from c in serContext.Customers
                //            where c.CustomerID == "ALFKI"
                //            select c;
                //int custCount = alfki.AsEnumerable<Customers>().Count<Customers>();

                bool test = serContext.TryGetEntity<Customers>(
                    custUri, out customerTest);

    -------------------------------------------------------------------------------

    If the comment part is released, the result of the "test" is true. The result of the "test" is false now. So it is obviously that the URI is correct. So is there any problem in my code?

    Thanks,
    Cloud.

    Monday, March 30, 2009 2:40 AM

Answers

  • TryGetEntity only retrieves entities that are being tracked by the DataServiceContext.  Hence, this will not return true until the entity has been retrieved from the data service.
    Monday, March 30, 2009 5:35 AM
    Moderator

All replies

  • TryGetEntity only retrieves entities that are being tracked by the DataServiceContext.  Hence, this will not return true until the entity has been retrieved from the data service.
    Monday, March 30, 2009 5:35 AM
    Moderator
  • TryGetEntity only retrieves entities that are being tracked by the DataServiceContext.  Hence, this will not return true until the entity has been retrieved from the data service.
    Thanks for your answer.

    Monday, March 30, 2009 5:41 AM