take a look at this example code:
public class Comment { private Comment() { } public Comment(string text, DateTime creationDate, string authorEmail) { Text = text; CreationDate = creationDate; AuthorEmail = authorEmail; } public virtual string Text { get; private set; } public virtual DateTime CreationDate { get; set; } public virtual string AuthorEmail { get; private set; } }
i know it’s considered bad practice to call virtual member functions from the constructor, however in NHibernate i need the properties to be virtual to support lazy loading. Is it considered OK in this case?
I’m pretty sure this is fine, but if your worried you could always just assign the properties after a parameter less constructor call.