0
votes

In my database I have field containg a comma delimited list of emails. How would I map that to a IList<string> in my model ?

2

2 Answers

2
votes

You should implement an IUserCollection, which would map your CSV column to an actual list of emails, then serialize it back on save.

0
votes

The table in question is not even First Normal Form, which is bad.

The only way you can possibly do that is something along these lines:

class Foo
{       
    private List<string> emails = new List<string>();       

    public string _Emails 
    { 
        get { return string.Join(",", emails.ToArray()); }
        set { emails = new List<string>(value.Split(',')); }
    }       

    public IList<string> Emails
    { 
        get { return emails; }          
    }
}

and map _Emails property.

Edit

One more solution is implemention your own IUserType or IUserCollection. Thus your model will be much prettier.