MbProg wrote:After inserting an order NopCommerce shows the Order.ID to the user. But I am integrating NopCommerce to our ERP system, thus inserting an order in our system via webservice and after inserting our system does return an ID. Now I want to save and show this ID in NopCommerce. Is there a way to insert my Id in Oder.ID column?
Mr. Sohel's suggestion is the right way but after that if you want to insert your Id to Order Table Id(OrderId) then, first you need to make "IDENTITY_INSERT" ON.
The query is something like
_dbContext.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Order] ON INSERT INTO [dbo].[Order]("+
"[Id],"+
"[OrderGuid]")" +
"VALUES('" + Convert.ToInt32(order.OrderId) + "',"+
"'" + new Guid(order.OrderGuid) + "')");
_dbContext.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Order] OFF");
Please remember the Id field also PK so the duplicate value will not be inserted.