This question is locked. New answers and comments are not allowed.
Hi,
For a lot of reasons I want to strictly separate Data Acces Layer classes (i.e. "persistent classes") form Business Logic Layer classes. In other words - let persistent classes stay as created by OpenAcces wizards. All the logic is placed in BLL classes.
Each such BLL class contains an instance of a DAL class and exposes its properties in direct or indirect way.
Some example:
There is a DAL class - "Person". It has two properties: PRName and PRSurname (corresponding db columns are named: PR_name and PR_surname).
And ther is a BLL class - "BPerson":
It's not complete - just an idea, of course.
At the Presentation Layer I don't want to even know about DAL classes.
And then - I want to display a grid with all persons. I ask my database with OpenAccess - but this way I get a list of DAL objects. Therefore I must create a new list of BLL objects (with a BPerson's static method; it returns an ObjectView, ready to ):
And at the Presentation Layer I have a simple statement:
Well, it works in general. But what about it's efficiency? I hope that constructing BLL objects (this way) doesn't affect lazy loading of DAL objects?
I would be very grateful for your opinions.
Regards
Tomasz
For a lot of reasons I want to strictly separate Data Acces Layer classes (i.e. "persistent classes") form Business Logic Layer classes. In other words - let persistent classes stay as created by OpenAcces wizards. All the logic is placed in BLL classes.
Each such BLL class contains an instance of a DAL class and exposes its properties in direct or indirect way.
Some example:
There is a DAL class - "Person". It has two properties: PRName and PRSurname (corresponding db columns are named: PR_name and PR_surname).
And ther is a BLL class - "BPerson":
| public class BPerson |
| { |
| private Person thePerson; |
| public string Name |
| { |
| get { return thePerson.PRName; } |
| set { thePerson.PRName = value; } |
| } |
| // Surname property is very similar |
| public string FullName |
| { |
| get { return Name + " " + Surname; } |
| } |
| public BPerson(Person pPerson) |
| { |
| thePerson = pPerson; |
| } |
| } |
At the Presentation Layer I don't want to even know about DAL classes.
And then - I want to display a grid with all persons. I ask my database with OpenAccess - but this way I get a list of DAL objects. Therefore I must create a new list of BLL objects (with a BPerson's static method; it returns an ObjectView, ready to ):
| public static Telerik.OpenAccess.ObjectView GetAllPersons() |
| { |
| ObjectProvider provider = new ObjectProvider(); |
| IObjectScope scope = MyObjectScopeProvider.ObjectScope(); |
| IQueryResult result = scope.GetOqlQuery("select * from PersonExtent").Execute(); |
| provider.ResultMethod = Telerik.OpenAccess.ObjectProvider.ResultMethodType.Manual; |
| List<BPerson> res = new List<BPerson>(); |
| foreach (Person ou in result) |
| res.Add(new BPerson(ou)); |
| provider.ObjectSource = res; |
| Telerik.OpenAccess.ObjectView view = new Telerik.OpenAccess.ObjectView(); |
| view.ObjectProvider = provider; |
| view.RootType = typeof(PersonB); |
| return view; |
| } |
| RadGrid1.DataSource = BPerson.GetAllPersons().List; |
Well, it works in general. But what about it's efficiency? I hope that constructing BLL objects (this way) doesn't affect lazy loading of DAL objects?
I would be very grateful for your opinions.
Regards
Tomasz