I’ve got an easy entity model
Bank 1—∞ User 1—∞ Session
In partial class Bank i’ve got to store an object Clock set during Bank creation.
Is it possible to retrieve this Clock object from inside a Session method and, of course, no Bank parameter passed?
Some code
public partial class Bank : IBank
{
private IClock _bankClock;
public IClock Clock
{
get { return _bankClock; }
set { _bankClock = value; }
}
}
public partial class Session : ISession
public bool MyMethod()
{
var test = (dc.Session.Include("User.Bank").Where(t => t.session_id == session_id));
var temp = test.First().User.Bank.Clock.Now();
}
when calling MyMethod i get Object reference not set to an instance of an object. and it is referred to the Clock property. Have you got any hints to retrieve a custom object from a LINQ query?
Thank you, Best Regards
more code
//CreateBank
public IBank CreateBank(string bankName, int valuePassedInCreateMethod, Clock bankClock)
{using (var dc = new Database1Entities(Functions.ToEntitiesConnectionString(connectionString)))
{
_dbField=valuePassedInCreateMethod;
bankReturn=(from c in dc.Bank
where c.bank_name == bankName
select c).First();
bankReturn.Clock = bankClock;
dc.SaveChanges();
return bankReturn;
}
}
Check object creation _bankClock, have you assigned some value to it?
See if I am close to your requirement. I get this working