I want to use System.Lazy to Lazy Initialization of my List in my Entites:
public class Questionary
{
private Lazy> _questions = n
You could do something like this:
public class Questionary
{
private Lazy> _questions =
new Lazy>(() => new List());
public IList Questions
{
get { return _questions.Value; }
set { _questions = new Lazy>(() => value); }
}
}
However, I don't see why you need Lazy
here at all. There is no benefit in using it, because the initialization of a new List
should be the same as the initialization of a new Lazy
...
I think it would be enough to keep it as simple as this:
public class Questionary
{
private IList _questions = new List();
public IList Questions
{
get { return _questions; }
set { _questions = value; }
}
}
or
public class Questionary
{
public Questionary()
{
Questions = new List();
}
public IList Questions { get; set; }
}