I am designing my entity for my web application. I have a lookup table for Designation, Country etc. How i create entities for this concept and how i code in DAL layer..
From there i got a nice solution. But i have the confusion is as per the thread we need to create seperate entity for eah item in the look up and created Generic class in DAL. But in the future if i need one more entry in the lookup master what i do? I need
to add one mor entity and handle the code in all layers othe than DAL?
Regards,
Akhil Raj K R
Please Mark as Answer if it helps u...
General practice for lookup entity is to store it in common table rather than creating separate table for Designation, country, etc. Create general table as below.
LookUpID
Name
Description
ParentLookUpID
1
Country
Country
NULL
2
India
India
1
3
US
US
1
4
Designation
Designation
NULL
5
Manager
Manager
4
6
Engineer
Engineer
4
7
UK
UK
1
Once you adopt such generic table design, then after you can create generic DAL, entity based on it.
Yea in the back end side i am ok. My confusion is in the business entity side only. Even if table is generic, in the entity side i created seperate entity for each type. So if i have one more entry in the lookup in future howe i handle. Again i add one
more entity? or any better approach is there?
Regards,
Akhil Raj K R
Please Mark as Answer if it helps u...
In the code side also you can create entity/class which represent your back end table as follow.
public class CodeLookUp
{
public int LookUpID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int? ParentLookUpID { get; set; }
}
Once above class list is populated with table rows, we can easily filter it with
.Wherebased on ParentLookUpID value.
thanks. This is good idea. Sorry i am not debating but need to know the better solution. As per technical this is ok and is easy for extenstention. But as per business functionality is it ok? I mean i read that business entities are based on business and
create seperate entit for each business objects. Kindly give advise on this. Sorry if i am going in wrong way
Regards,
Akhil Raj K R
Please Mark as Answer if it helps u...
I mean i read that business entities are based on business and create seperate entit for each business objects.
Akhil, I do agree with you that separate entity for business object... but when you are using any ER model concept in your OO application, generally at that time our business entity represent our DB object i.e. Table, View, etc. and in case of generic lookup,
i think this pattern is widely adopted in many application. I cant recall any name right now but I have seen this pattern used in many application i worked till. I think in DNN(dotNetNuke) also they are following such table structure.
(I am not sure about DNN's recent version, but i think they are using. Again I am not sure about DNN)
akhilrajau
Participant
1744 Points
537 Posts
Generic Lookup Class
Sep 12, 2012 12:59 PM|LINK
hi,
I am designing my entity for my web application. I have a lookup table for Designation, Country etc. How i create entities for this concept and how i code in DAL layer..
I got th following article related to this
http://forums.asp.net/t/1273449.aspx/2/10
From there i got a nice solution. But i have the confusion is as per the thread we need to create seperate entity for eah item in the look up and created Generic class in DAL. But in the future if i need one more entry in the lookup master what i do? I need to add one mor entity and handle the code in all layers othe than DAL?
Akhil Raj K R
Please Mark as Answer if it helps u...
Nandip Makwa...
Participant
1267 Points
293 Posts
Re: Generic Lookup Class
Nov 20, 2012 04:45 PM|LINK
General practice for lookup entity is to store it in common table rather than creating separate table for Designation, country, etc. Create general table as below.
LookUpID
Name
Description
ParentLookUpID
1
Country
Country
NULL
2
India
India
1
3
US
US
1
4
Designation
Designation
NULL
5
Manager
Manager
4
6
Engineer
Engineer
4
7
UK
UK
1
Once you adopt such generic table design, then after you can create generic DAL, entity based on it.
Software Engineer by Profession, Learner by Passion!
akhilrajau
Participant
1744 Points
537 Posts
Re: Generic Lookup Class
Dec 03, 2012 04:17 AM|LINK
hi friend,
Yea in the back end side i am ok. My confusion is in the business entity side only. Even if table is generic, in the entity side i created seperate entity for each type. So if i have one more entry in the lookup in future howe i handle. Again i add one more entity? or any better approach is there?
Akhil Raj K R
Please Mark as Answer if it helps u...
Nandip Makwa...
Participant
1267 Points
293 Posts
Re: Generic Lookup Class
Dec 03, 2012 04:31 AM|LINK
In the code side also you can create entity/class which represent your back end table as follow.
public class CodeLookUp { public int LookUpID { get; set; } public string Name { get; set; } public string Description { get; set; } public int? ParentLookUpID { get; set; } }Once above class list is populated with table rows, we can easily filter it with .Where based on ParentLookUpID value.
Software Engineer by Profession, Learner by Passion!
akhilrajau
Participant
1744 Points
537 Posts
Re: Generic Lookup Class
Dec 04, 2012 05:15 AM|LINK
thanks. This is good idea. Sorry i am not debating but need to know the better solution. As per technical this is ok and is easy for extenstention. But as per business functionality is it ok? I mean i read that business entities are based on business and create seperate entit for each business objects. Kindly give advise on this. Sorry if i am going in wrong way
Akhil Raj K R
Please Mark as Answer if it helps u...
Nandip Makwa...
Participant
1267 Points
293 Posts
Re: Generic Lookup Class
Dec 12, 2012 05:49 AM|LINK
Akhil, I do agree with you that separate entity for business object... but when you are using any ER model concept in your OO application, generally at that time our business entity represent our DB object i.e. Table, View, etc. and in case of generic lookup, i think this pattern is widely adopted in many application. I cant recall any name right now but I have seen this pattern used in many application i worked till. I think in DNN(dotNetNuke) also they are following such table structure. (I am not sure about DNN's recent version, but i think they are using. Again I am not sure about DNN)
Software Engineer by Profession, Learner by Passion!
akhilrajau
Participant
1744 Points
537 Posts
Re: Generic Lookup Class
Dec 14, 2012 03:42 AM|LINK
thanks friend thanks foir the clarification
Akhil Raj K R
Please Mark as Answer if it helps u...