Custom where clause with string?

I am returning a dataset using SubSonic.SqlQuery of two related objects, but I cannot figure out how to execute this where clause:

Month(SubmittedOn)=Month(GETDATE()) AND Year(SubmittedOn)=Year(GETDATE())

      

I tried to do it like this, but I didn't like the .IsEqualTo (line):

.Where("Month(SubmittedOn)").IsEqualTo("Month(getdate()")

      

0


a source to share


2 answers


You can only pass the value to the constraint method (IsEqualTo) in SubSonic so that the following will get all strings presented in March:

.Where("Month(SubmittedOn)").IsEqualTo(3)

      



Listed below are all lines featured in the current month:

.Where("Month(SubmittedOn)").IsEqualTo(DateTime.Now.Month)

      

0


a source


It looks like you are missing a parenthesis. Try:



.Where("Month(SubmittedOn)").IsEqualTo("Month(getdate())")

      

0


a source







All Articles