Skip to content

Documentation: improve enum string literal example #434

Open
@zspitz

Description

@zspitz

The following example:

using (var context = new EntityContext())
{
    var list = context.Customers.Where("OrderDate.DayOfWeek = @0", DayOfWeek.Monday); 
}

is supposed to demonstrate how Dynamic LINQ parses a string literal embedded inside a Dynamic LINQ string as an enum. But the example only shows how it's possible to pass in an actual enum value to Dynamic LINQ, via the @0 parameter. A better example would be:

using (var context = new EntityContext())
{
    var list = context.Customers.Where("MyEnumProperty = \"FirstValue\""); 
}

where the enum value is itself embedded as a string literal inside the Dynamic LINQ string.

Also, it should be noted that as of #450 , all the enum types defined in mscorlib are available directly, not as string literals. So to use DayOfWeek, it doesn't need to be wrapped in ":

using (var context = new EntityContext())
{
    var list = context.Customers.Where("OrderDate.DayOfWeek = DayOfWeek.Monday"); 
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions