asp.net - When assigning values to EntityRef ID fields in Linq to Sql, can EntityRef still delay load? -


I've got an ASP.NET MVC app that uses SQL for data access to SQL.

Say I have two objects: An order object that has a foreign key for customer object by a custom ID, then in my order class, you have to look at two properties:. An integer CustomerID field, and an EntityRef member can not be accessed by a customer property

Editing or submitting an order, CustomerID will update my MVC application instead of updating the Customer Property directly to the Order class directly field Saves us from having to bring a customer record, and I code binding automatically as long as the submission request is a customer ID entry The Nptti can use the default model to fill.

This works fine, however, later in some other part of the code - as a business rule part, some logic will reach the customer property of the order object. For example:

  if (order.Customer.HasPreviousOrders) then ...  

Although the CustomerID field is set to, the Customer field is empty, So this business rule throws an exception.

I use EntityRefs to delay that loading in Linq 2 Sql. My question is, is there any way of triggering delayed loading on EntityRef of an object, if the ID field has been modified?

We have a dynamic rule engine, so I do not have the control of the need for foreign key items. I will not have to go through all my controllers to install EntityRef & lt;> values ​​directly

thanks for help

OK, no buyer. It seems like what I'm trying to do, it is not possible - or maybe not a good idea.

I went ahead and implemented the code, so I'm setting up an association object property instead of ID property so that business rules can be processed.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -