Hi,
I am trying to load some entities from the database and in some cases ObjectConstructed is not getting fired. Here is what I have tried:
I have Table Person and Stuff. Stuff references to Person (one to many. )
<p>TelerikContext context =
new
TelerikContext();<br></p><p>context.Events.ObjectConstructed += (s, e) =>{
//my logic };</p><p>//Use case 1:</p><p>var people = context.People.ToList(); //in this case ObjectConstructed gets fired [people.Count] amount of times</p><p></p><p>//Use case 2:</p><p>var people = context.Stuff.Select(s=>s.Person).ToList(); // in this case I might have 5 person on my collection, but ObjectConstructed never gets fired. </p>
I want ObjectConstructed to be fired every time i load an object from DB so that I can do my logic accordingly. Can you please instruct me how to acheive that?
Thank you!
5 Answers, 1 is accepted
I couldn't edit my questions. Here I am reposting the use case.
TelerikContext context = new TelerikContext();
context.Events.ObjectConstructed += (s, e) =>{ //my logic };
//Use case 1:
var people = context.People.ToList(); //in this case ObjectConstructed gets fired [people.Count] amount of times
//Use case 2:
var people = context.Stuff.Select(s=>s.Person).ToList(); // in this case I might have 5 person on my collection, but ObjectConstructed never gets fired
Hi,
Is there any progress on the issue above? I am waiting for the response. I need to take actions according to the answer.
Thanks,
Dilshod
Such an issue was never reported and I was not able to reproduce the issue. I prepared a sample application to demonstrate that it is working correctly. You could find the sample attached.
I hope that helps.
Regards,
Boris Georgiev
Telerik
Hello Boris,
Finally I was able to reproduce the issue. To be able to reproduce the issue, please replace the: [xxxxx].IsIdentity(KeyGenerator.Autoinc) with [xxxxx].IsIdentity(). If you do that, object constructed doesn't get fired when you load the entity through select.
Thanks,
Dilshod
Thank you for the guidance how to reproduce the issue. After a long research we found out that this is a bug in Telerik DataAccess. Unfortunately I can not give you a time frame if we will fix the issue, when you can expect it.
Find your Telerik Points updated for the new bug you have helped us identify.
Regards,
Boris Georgiev
Telerik by Progress