I'd using 3 tier architecture on my web project. DAL -> EF 4 wrapper with classic CRUD method (AddEntity, RemoveEntity adn so on) BAL -> business logic and query exposing (selectByName, byCity, bySomeOtherProperty). UI - Aspx page
My problem is about navigationProperty exposed by EF. If I have a CustomerRepostiory, aspx side I don't want allow operation on entity that are not Customer, supposing follwing POCO class:
public class Customer
{
public int Id {get; set;}
public string Name {get; set;}
public ICollection<Orders> Order{get;set;}
}
and on aspx you execute something like this:
var customer = bll.getCustomerByName("alex");
customer.Order.Add(new ..) // BAD, I don't want allow it
What should I do? Maybe I must create a poco class wrapper in order to "hide" some properties? Which really is best approach?