Subsonic operation - bit in Where section

I am trying to do something like this:

int count = new Select().From(tblSchema).Where("Type & 1").IsEqualTo("1").GetRecordCount();

      

And the error message:

Incorrect syntax near '&'.

Must declare a scalar variable "@Deleted".

Can you do this with SubSonic?

0


a source to share


3 answers


Must declare scalar variable "@Deleted"

The second error will be caused by using logical deletes on the table you are querying (the table has an isDeleted or Deleted column).



But I'm going through the code, I'm not sure how this parameter gets there. The SqlQuery.GetRecordCount method does not call CheckLogicalDelete () from what I can tell. Is this error message related?

0


a source


It looks like a bug in the way SubSonic calls its parameters when generating the SQL to be executed.

What happens is SubSonic looks for "Type and 1" and then creates a comparison parameter named @Type & 10, which is not a valid SQL parameter name. This way you will get the following SQL from the original query. You have to report the bug http://code.google.com/p/subsonicproject/



At the same time, you can work around the problem with an inline query:

http://subsonicproject.com/docs/Inline_Query_Tool

0


a source


A bit fuzzy as to what you are trying to accomplish, but here is a better guess.

int count = new Select().From(tbl.Schema).Where(tbl.TypeColumn).IsEqualTo(true).GetRecordCount(); 

      

-1


a source







All Articles