Fluent-NHibernate mapping

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 ?

Answers


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


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.


Need Your Help

Trying to install pymc error: invalid command 'config_fc'

python git pycharm pymc

I'm trying to install pymc on osx snow leopard, but I'm getting nowhere.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.