locked
Saving changes to db RRS feed

  • Question

  • I am using LINQ to Entities and REST to bring data from and push it back to the db, but I can't figure out how to get the save to work correctly.  When I try to link my in-memory, updated copy of the entity to the entity that came from the db, I get the following error:

    "The closed type Lynxphere.WindowsClient.LynxphereDataServices.Customers does not have a corresponding Customers settable property."

    I'll paste my code below.  Thanks for the help.

     
    var query = Program.Proxy.Customers.Where(p => p.ContactId == g); //g is set elsewhere 
     
    Program.Proxy.AddLink(query.First(), "Customers", CustomersBindingSource.CurrencyManager.Current); 
                Program.Proxy.BeginSaveChanges(System.Data.Services.Client.SaveChangesOptions.Batch, 
           delegate(IAsyncResult ar) 
           { 
                 Program.Proxy.EndSaveChanges(ar); 
           }, 
           customersBindingSource.CurrencyManager.Current); 

    • Moved by Noam Ben-Ami - MSFT1 Monday, January 12, 2009 6:08 PM This is a data services question. (Moved from ADO.NET Entity Framework and LINQ to Entities to ADO.NET Data Services)
    Monday, January 12, 2009 1:33 PM

Answers

  • Hello,

    The error comes from this line:

    Program.Proxy.AddLink(query.First(), "Customers", CustomersBindingSource.CurrencyManager.Current); 

    The problem is that the entity you get from query.First() (I'm assuming it's Customers) doesn't have a property called "Customers".Check the metadata and correct it. 

    Hope this helps.

    Best regrads,
    Monica Frintu
    Monday, January 12, 2009 11:23 PM
    Moderator

All replies

  • Hi,
     Can you share the Schema of the CLR type of instance query.First() ?
     It looks like the relation Name "Customers" is not being recognised by the Client Library
     
    Phani Raj Astoria
    Monday, January 12, 2009 6:21 PM
    Moderator
  • I'm afraid that I'm not exactly sure what you are asking for.  Can you dumb it down a little for me?  Thanks.
    Monday, January 12, 2009 6:38 PM
  • Hello,

    The error comes from this line:

    Program.Proxy.AddLink(query.First(), "Customers", CustomersBindingSource.CurrencyManager.Current); 

    The problem is that the entity you get from query.First() (I'm assuming it's Customers) doesn't have a property called "Customers".Check the metadata and correct it. 

    Hope this helps.

    Best regrads,
    Monica Frintu
    Monday, January 12, 2009 11:23 PM
    Moderator