Hacker News new | past | comments | ask | show | jobs | submit login

Personally I don't prefer the SQL syntax in Linq. I like using EF Core, but with regular C# style statements



I really think this depends on the situation. If you have an objet with foreign key relations to a lot of other objects then using lambda syntax is most likely preferred:

    var res = context.Objects.Include(x=> x.ChildObjects)
But if you have to do joins then definitely query syntax is much clearer. For example the join above in lambda syntax looks like this:

    var query = await context.Objects
                             .Join(context.ObjectChildren, 
                                   obj => obj.Id,
                                   objChild => objChild.ObjId,
                                   (obj, objChild) => new { Obj = obj, ObjChild = objChild })
                             .Where(objAndObjChild => objAndObjChild.Obj.Name == "SomeName")
                             .ToListAsync();




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: