Search code examples
entity-frameworkasp.net-core.net-coreasp.net-core-2.0linq-method-syntax

Entity Framework Method Syntax Naming Convention


What are some naming conventions utilized for Entity Framework queries? Example, following code utilizes 'e. Why do they use e? And what are naming convention strategies for delegate abbreviation in method syntax? This question is not asking for opinion, just common naming convention.

    public static string GetBooksByPrice(BookShopContext context)
    {
        var result = context.Books
            .Where(e => e.Price > 40)
            .OrderByDescending(e => e.Price)
            .Select(e => new
            {
                e.Title,
                e.Price
            }).ToList();

Solution

  • You can name it to book as well rather than e, you can follow the same naming conventions other than reserved C# Keywords

    It has nothing to do with Entity Framework you're using C# lambda expressions to query the database which in turn is translated to SQL server statement

    You can read about Lambda expressions here

    C# Lambda Expressions