DDD (Domain Driven Design), how to handle entity state changes, and encapsulate business rules that requires large amount of data to be processed

后端 未结 4 888
萌比男神i
萌比男神i 2021-01-31 04:47
public class Person
{
    public IList SpecialBirthPlaces;
    public static readonly DateTime ImportantDate;
    public String BirthPlace {get;set;}

             


        
4条回答
  •  佛祖请我去吃肉
    2021-01-31 05:00

    IMO the best approach performance-wise would be to create a stored procedure in your db and mark entity on property changed event to invoke it when committing changes to db (SaveChanges() call). ObjectContext.ExecuteFunction is your friend in that case.

    Put all your logic of birthplace lookup and update in that sproc. Make sure sproc is included in the transaction - so that changes are rolled back if update fails.

    Edit: Sorry for not DDD related answer.

提交回复
热议问题