This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
When i instantiate new entity: SomeEntity someEntity = new SomeEntity(); it has Id = 0. I use stored procedures for saving entities to database. They checks passed Id: if Id = null, then entity must be created, else updated. I have records in my database with Id = 0. Therefore stored procedures can not check Id properly. Could you please add option for selecting initial Id value: null or 0 or something else. related thread: Selecting table row with Id = 0 |
|
|
A (nonzero) ID will be assigned when you add the entity to a unit of work. So if you add the entity to a UOW before performing your check, you'll be okay. |
|
|
I am new to Lightspeed. I just purchased the enterprise license. I have a question related to this post. I can add successfully to the database. But once I add an item, I want to retrieve the new ID that got assigned to the object once it got added to the database. I want to return that id an use it to display information on the confirmation screen. Can you please help me with this. |
|
|
This is available as entity.Id. For example: using (IUnitOfWork uow = context.CreateUnitOfWork()) In fact the Id is usually allocated and available for display when you add the entity to the unit of work (IUnitOfWork.Add). The exception is if you are using the IdentityColumn identity method. In this case the Id is not available until after SaveChanges (because the Id is allocated by the database during insert). |
|