linq to sql - How to implement lookup table in mvc framework? -
asp.net mvc2: have many dropdownlists in mvc application. @ first, started creating table each 1 unique id , name , referring them in controllers , views. application got bigger, , suggested use lookup table, contains lookuptype , lookupvalue compound primary key , fill values dropdownlists in it. i've looked on internet, method used mvc 1 table each dropdownlist! can explain me how can implement it, , in detail please becoz i'm totally lost. link tutorial great. i'm using vb.net , linq sql.
suppose tables have columns id
, name
, value
. having 1 table table this:
create table lookup ( lookupid int not null identity primary key, lookuptypeid int not null references lookuptype(lookuptypeid), name nvarchar(50) not null, value int not null, unique(enumtypeid, name) ) go
this table make sure within same type names don't clash.
anyway. of course have similar application (not data) model class
public class enumvalue { public int id { get; set; } [required] public string name { get; set; } [required] public int value { get; set; } }
so whenever values of type can generate ilist<enumvalue>
of them , feed them particular drop down.
since didn't provide valuable data table , class omit column/property value
, because depending on inner workings may not needed @ all. know best because know application requirements. instead of column/property id trick.
Comments
Post a Comment