KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If you have, for example, a database table called Person (ID,Name etc) what kind of object should the data access tier return to the business tier? I'm thinking something like this: //data access tier public class DataAccess{ public interface IPerson{ int ID{ get; set; } string Name{ get; set; } } internal class Person : IPerson{ private int id; private string name; public int ID{ get{return id; } set{ id=value; } } public int Name{ get{retutn name; } set{ name=value; } } public static IPerson GetPerson(int personId) { //get person record from db, populate Person object return person; } } //business tier public class Person : IPerson{ private int id; private string name; public int ID{ get{return id;} set{id=value;} } public string Name{ get{return name;} set{name=value;} } public void Populate(int personId){ IPerson temp = DataAccess.GetPerson(personId); this.ID = temp.ID; this.Name = temp.Name; } } But this all seems a little cumbersome? Is there a more elegant solution to this problem? Should I return a DataRow from the data access layer to the business layer instead?
Tags (comma-separated)
Save Edits
Cancel