Entity Framework Method Syntax Naming Convention

317 views Asked by At

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();
2

There are 2 answers

1
Ikram Shah On BEST ANSWER

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

0
sina_Islam On

There is no suggested naming convention for delegate. If you see the linq at github Select. These are method parameters so you can pass any name but type need to be same.