I have two models
public class Indicator
{
public long IndicatorID { get; set; }
public string Name { get; set; }
public int MaxPoint { get; set; }
public string Comment { get; set; }
public DateTime DateChanged { get; set; }
public DateTime DateCreated { get; set; }
public virtual IList<CalculationType> CalculationTypes { get; set; }
}
public class CalculationType
{
public long CalculationTypeID { get; set; }
public string UnitName { get; set; }
public int Point { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateChanged { get; set; }
public virtual Indicator Indicator { get; set; }
}
I have a factory database
public class DatabaseFactory
{
private StankinQuestionnaireEntities dataContext;
public StankinQuestionnaireEntities Get()
{
return dataContext ?? (dataContext = new StankinQuestionnaireEntities());
}
}
and a property that refers to databaseFactory
protected StankinQuestionnaireEntities DataContext
{
get { return dataContext ?? (dataContext = DatabaseFactory.Get()); }
}
I am using Autofac and regizer DatabaseFactory
builder.RegisterType<DatabaseFactory>().As<IDatabaseFactory>().InstancePerRequest();
in my repository I try to get data from the navigation property in two ways

first line works fine (CalculationType contains one element)

but the second line returns null in the CalculationType property

Why?
UPDATE
I found that if you delete the line ".InstancePerRequest ()", everything will work. But that doesn't suit me.
UPDATE2 for any reason, ef proxy class not created