How to get newly inserted ID via WCF

Mar 26, 2009 at 7:00 AM
Hi.

I can get the newly inserted ID when I am using class libraries, but not via WCF. I think this is because the object passed in for  insert is not by reference.  Let me know if there are any issues with this change to service contract & implementation.  If not, it would be good for future templates to be updated with the change.  Thanks

FROM:

 

public Int32 Insert(MyNamespace.MyObject obj){

 

 


//what is the point of creating a temp object. Think this was copied from Update Method where there is a point, so will delete it

MyNamespace.MyObject 
temp = new MyNamespace.MyObject ();

 

 

 

temp.ID = obj.ID;

 

 

temp.Name = obj.Name;

 

objRepository.Insert(obj);

CommitChanges();

}





TO:


public

 

Int32 Insert(MyNamespace.MyObject obj)

 

{

objRepository.Insert(obj);

CommitChanges();

 

//return the new objectID

return
obj.ID;

 

}

Coordinator
Mar 30, 2009 at 10:47 AM
It is a good request. we will give it a space in the current development plan.
You can edit the templates easy to achieve it.
Thank you.
Negm.