Given the following classes,
public class MyClass
{
public string Property { get; set; } //mapped to column 'property'
}
public class MyContext : DbContext
{
public DbSet<MyClass> MyClasses { get; set; } //mapped to table dbo.MyClasses
}
I'm trying to generate the following SQL request, using Linq to SQL and EF Core 3.1.
SELECT * FROM dbo.MyClasses
WHERE property > 'constant'
Any help appreciated.
Attempt 1:
var result = dbContext.MyClasses.Where(c => c.Property > "constant").ToList();
//Does not compile
Attempt 2:
var result = dbContext.MyClasses.Where(c => c.Property.CompareTo("constant") > 0).ToList();
//SELECT * FROM dbo.MyClasses
//WHERE
//CASE
// WHEN property = 'constant' THEN 0
// WHEN property > 'constant' THEN 1
// WHEN property < 'constant' THEN -1
//END > 0