question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataConnection.OnEntityCreated not called

See original GitHub issue

Hi, I’m trying to use OnEntityCreated event. This is my C# code:

        private static void Main()
        {
            DataConnection.DefaultSettings = new MySettings();
            Configuration.Sql.GenerateFinalAliases = true;

            using var db = new WipDB("Wip");
            db.OnEntityCreated += (e) => Console.WriteLine(e.Entity.GetType().Name);

            var result = from ncCode in db.NcCode
                         join ncGroupMember in db.NcGroupMember
                         on ncCode.Handle equals ncGroupMember.NcCodeOrGroupGbo
                         where
                             ncGroupMember.NcGroupBo == "NCGroupBO:" + ncCode.Site + ",CATAN_AUTO" ||
                             ncGroupMember.NcGroupBo == "NCGroupBO:" + ncCode.Site + ",CATAN_MAN" ||
                             ncGroupMember.NcGroupBo == "NCGroupBO:" + ncCode.Site + ",CATAN_ALL"
                         select new AllowedNcCodeOutput { NcCodeBo = ncCode.Handle, NcCode = ncCode.NcCodeColumn, NcCodeDescription = ncCode.Description };

            var sql = result.ToString();
            Console.WriteLine(sql);
            var resultItems = result.ToList();
        }

The issue is that Console.WriteLine(e.Entity.GetType().Name is never called even if result.ToList() contains more than 7000 items. I’m expecting that OnEntityCreated will be raised for each entity of type AllowedNcCodeOutput that is created by the query. Am I wrong?

Thank you!

Environment details

inq2db version: 3.0.0-rc.2303 Database Server: Oracle Database Provider: Oracle.ManagedDataAccess.Core (3.0.0-rc.2303) Operating system: Windows 10 .NET Framework:.NET Core 3.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Jun 16, 2020

Yes, You give me better idea:

public static IEnumerable<T> AsChecked<T>(this IEnumerable<T> source)
{
    foreach (var item in source) 
    {
        /// run validator
       yield return item;
    }
}
0reactions
filippobottegacommented, Jun 16, 2020

Thank you for let me find a different way to solve my issue: IQueryable inherits IEnumerable and I can change the entities one by one using yield keyword. I want to avoid to allocate all entities in a list using ToList() before memory compression. The only drawback is that I need to change every query instead to implement a single event. Please feel free to close this issue if you want.

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

DataConnection.OnEntityCreated not called with LoadWith
OnEntityCreated is not called for the entities of the subquery. The reason seems to be that the DataConnection is cloned for subqueries but ......
Read more >
Newest 'connection' Questions - Page 32
typeORM combine next.js can not connect database with error ... I am implementing a calling app and I want to do a self-managed ......
Read more >
TMS Aurelius Manual
object. If the very Next call returns false, it means the cursor has no records. 85<br />. <strong>TMS</ ...
Read more >
Diving Into Microsoft Net Entity Framework | PDF
This does not require a developer to have an intense knowledge of database or its schema. This innovation was named as. Entity Framework...
Read more >
TMS Aurelius Manual - TMS Software - manualzz.com
You do that by adding a unit named Aurelius.SQL.XXX (where XXX is the name of SQL dialect) to any unit of your application,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found