lundi 15 juin 2015

Entity framework forien keys

I am new in MVC and Entity framework, so I have some problem in my first project. So sorry if my question is to noob :(

What I have at this point:
I have table users(ID, Name, Password, TypeID, StatusID) and I have lookup table for this fields TypeID, StatusID UserTypes and UserStatuses.

Here is some code for more clarity

CREATE TABLE [dbo].[Users](
    [ID] [int] NOT NULL,
    [Name] [varchar](512) NOT NULL,
    [Password] [varchar](128) NOT NULL,
    [TypeID] [int] NULL,
    [StatusID] [int] NULL
)

CREATE TABLE [dbo].[UserStatuses](
    [ID] [int] NOT NULL,
    [Description] [nvarchar](128) NULL
)


CREATE TABLE [dbo].[UserTypes](
    [ID] [int] NOT NULL,
    [Description] [nvarchar](128) NULL
)

In UserStatuses Table I store "active", "Blocked" and in UserTypes "Admin", "User", "guest"

Values in UserTypes mey change in future so, I don't wont to convert Users.TypeID field in Enum.(this is important for me !)

What I need:
How display user friendly values "active", "Blocked" for StatusID and "Admin", "User", "guest" for TypeID field, instead of number editor when I am generating view ?

link to some good article is welcome Smile :)

Aucun commentaire:

Enregistrer un commentaire