Why, when using ServiceStack OrmLite, does the error "a variable referring to the scope but not defined" appear?

I have a SQL Server Employee table with an EntryDate column defined as DATETIME .

I also have the following poco:

 public class Employee { public int Id {get; set;} public DateTime EntryDate {get; set;} ... } 

When I query the table using:

 Db.Select<Employee>(e => e.EntryDate >= new DateTime(2014, 8, 15)); 

Or:

 Db.Select<Employee>(q => q.Where(e => e.EntryDate >= new DateTime(2014, 8, 15))); 

I get what I expect, however , when I try to run:

 Db.Select<Employee>(e => e.EntryDate.Date >= new DateTime(2014, 8, 15).Date)); 

Or:

 Db.Select<Employee>(q => q.Where(e => e.EntryDate.Date >= new DateTime(2014, 8, 15).Date)); 

I get:

variable 'e' of type "Employee" referenced by scope "', but this is not defined

Just for confirmation, writing raw SQL also works great.

Any ideas?

+5
source share

Source: https://habr.com/ru/post/1200606/


All Articles