Someone asked me about this so I thought I'd share here. The question was around how you can work with database generated values and have them returned to the client after the insert.
My experiment ran like this.
I created a table;
create table test
(
id int identity primary key not null,
someColumn nvarchar(30) not null
)
I created a website project, added an entity model which only has the table above in it and then added an ADO.NET Data Service and exposed my entity model through it in the standard way.
I then used webdatagen.exe in order to read the metadata and build client proxy code. I then used that proxy class (called demoEntities below) to write a client;
demoEntities entities = new demoEntities(
"http://localhost:32768/WebSite1/ServiceOne.svc");
entities.MergeOption = MergeOption.OverwriteChanges;
test newTestRecord = new test()
{
someColumn = "foo"
};
entities.AddObject("test", newTestRecord);
entities.SaveChanges();
Console.WriteLine("New id is {0}", newTestRecord.id);
and that all seemed to work ok for me - the newly created entity id being returned as part of the newTestRecord record.
Posted
Wed, Mar 12 2008 10:29 AM
by
mtaulty