1

Say, the field of Race in my table has values like "W,A" (white and asian), "H, W" (hispanic and white), "I" (Indian only).

How can I use Entity Framework to build this field into: public string[] Race {get;set;} or public List<string> Race {get;set;} instead of public string[] Race {get;set;}?

I believe it should be possible. Can someone here help me? Thank you.

1 Answer 1

4

Since Entity Framework uses partial classes you can extend it, e.g. if want to extend the entity SomeEntityName something like this should work:

public partial class SomeEntityName
{
    public string[] RaceProperties
    { get { return Race.Split(','); } }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. That is really helpful. But is it possible to have both get and set? I am using a CheckBoxListFor in MVC3 as an editor for Race.
yes - you would have to map that to an update of the Race property, e.g. set { Race = string.Join(",", value); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.