I am willing to integrate the entity framework as my data layer.
I followed articles and generated poco entities using this tutorial: http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx
I have my own business objects. Here is my business object Brach:
public class Branch
{
public long BranchId { get; private set; }
public string BranchName { get; set; }
public string BranchCode { get; set; }
public Branch() { }
public void InsertBranch(Guid companyId)
{
using (var ctx = new Entities.Entities())
{
var branch = new T_STF_BRANCH() //This is generated POCO object
{
company_id = companyId,
branch_name = BranchName,
branch_code = BranchCode
};
ctx.T_STF_BRANCH.AddObject(branch);
ctx.SaveChanges();
}
}
public static IList<Branch> GetBranchesList(Guid companyId, long? branchId,
string branchName)
{
using (var ctx = new Entities.Entities())
{
var branchs = ctx.T_STF_BRANCH.Where(x =>
x.is_deleted == false &&
(branchId == null || x.branch_id == branchId) &&
(branchName == null || x.branch_name.Contains(branchName))).ToList();
}
//HERE I NEED SOMEHOW CONVERT THE POCO ENTITIES INTO MY BUSINESS ENTITIES...
}
}
I don't know how to convert the POCO entity into my business entity.
Where should I put the conversion from POCO and to POCO?