entity framework POCO template in a n-tiers design question
Posted
by bryan
on Stack Overflow
See other posts from Stack Overflow
or by bryan
Published on 2010-05-31T03:49:14Z
Indexed on
2010/05/31
3:52 UTC
Read the original article
Hit count: 615
HI all
I was trying to follow the POCO Template walkthrough . And now I am having problems using it in n-tiers design.
By following the article, I put my edmx model, and the template generated context.tt in my DAL project, and moved the generated model.tt entity classes to my Business Logic layer (BLL) project.
By doing this, I could use those entities inside my BLL without referencing the DAL, I guess that is the idea of PI; without knowing anything about the data source.
Now, I want to extend the entities (inside the model.tt) to perform some CUD action in the BLL project,so I added a new partial class same name as the one generated from template,
public partial class Company
{
public static IEnumerable AllCompanies()
{
using(var context = new Entities()){
var q = from p in context.Companies
select p;
return q.ToList();
}
}
}
however visual studio won't let me do that, and I think it was because the context.tt is in the DAL project, and the BLL project could not add a reference to the DAL project as DAL has already reference to the BLL.
So I tried to added this class to the DAL and it compiled, but intelisense won't show up the BLL.Company.AllCompanies() in my web service method from my webservice project which has reference to my BLL project.
What should I do now? I want to add CUD methods to the template generated entities in my BLL project, and call them in my web services from another project.
I have been looking for this answer a few days already, and I really need some guides from here please.
Bryan
© Stack Overflow or respective owner