This question is locked. New answers and comments are not allowed.
Hi,
I am looking at the Telerik ORM as an option for an application we are going to build which is graph heavy i.e. I need to be able to update/insert/delete graph items and submit in one transaction. I have had some success using the Telerik ORM buy have hit a stumbling block when trying to delete records.
My app will be web based and I need to work with graphs in a detached state. The above works fine for inserts and updates, but fails when deleting records with;
Update failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert the value NULL into column 'OrderId', table 'DemoDB.dbo.OrderItem'; column does not allow nulls. UPDATE fails.
I am clearly doing something wrong. Can anyone advise on what I should be doing?
Many thanks,
George
I am looking at the Telerik ORM as an option for an application we are going to build which is graph heavy i.e. I need to be able to update/insert/delete graph items and submit in one transaction. I have had some success using the Telerik ORM buy have hit a stumbling block when trying to delete records.
int orderId = 6;
Order detahcedOrder = null;
using (var context1 = new MyModel())
{
FetchStrategy fetchStrategy = new FetchStrategy();
fetchStrategy.LoadWith<
Order
>(e => e.OrderItems);
List<
Order
> orders = context1.Orders.Where(i => i.OrderId == orderId).ToList();
detahcedOrder = context1.CreateDetachedCopy<
Order
>(orders, fetchStrategy).FirstOrDefault();
}
var addMe = new OrderItem { Qty = 1, ProductId = 2 };
detahcedOrder.OrderItems.Add(addMe);
var updateMe = detahcedOrder.OrderItems.SingleOrDefault(h => h.OrderItemId == 8);
updateMe.Qty = updateMe.Qty + 5;
var removeMe = detahcedOrder.OrderItems.SingleOrDefault(h => h.OrderItemId == 9);
detahcedOrder.OrderItems.Remove(removeMe);
using (var context2 = new MyModel())
{
context2.AttachCopy(detahcedOrder);
context2.SaveChanges();
}
My app will be web based and I need to work with graphs in a detached state. The above works fine for inserts and updates, but fails when deleting records with;
Update failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert the value NULL into column 'OrderId', table 'DemoDB.dbo.OrderItem'; column does not allow nulls. UPDATE fails.
I am clearly doing something wrong. Can anyone advise on what I should be doing?
Many thanks,
George