we're using mvp , entity framework code first our project. basic functions we'll use dbcontext, wrap logic around adding profiles. validations , other rules.
so our object defined usual:
public class profile:baseentity { [key, databasegenerated(databasegeneratedoption.identity)] public guid profileid {get; set; } public string firstname {get; set; } //.... } i'd love have method can call this:
var newprofile = new profile { firstname = "john", ... } newprofile.insert(); // or _dbcontext.profile.add(newprofile); and have call our method our business rules:
public bool addprofile(profile thisprofile) { // our business return true; // or false if failed } i'm not sure best place put method is. can add profile.cs? should add dbcontext class?
i'm not sure best way, or best terms search for.
you can override validateentity method of dbcontext if need few cases
http://www.entityframeworktutorial.net/entityframework4.3/validate-entity-in-entity-framework.aspx
this validated when call savechanges();
Comments
Post a Comment