Hi all,
I have a newbie question that I can't seem to figure out myself:
I have a database table, "Table1", that holds a couple of Guid-identifer fields, EventID and CompanyID. These Guid-identifiers have their own "Get"-methods in the auto-generated DataRepository.Table1Provider object (GetByEventID() and GetByCompanyID()).
Now, Table1 holds more fields than just these two, so I would like to select all rows from Table1 where EventDate = SomeDate. Since "EventDate" doesn't have a Get-method like the two GUID-identifiers, I figured I could use: DataRepository.Table1Provider.Find("EventDate = '" + DateTime.Now + "'") to return rows that match this query.
And here's where the problem occurs. By looking in the SQL Profiler, I see that the query sent to the database looks something like this (simplified!):
Select EventID, CompanyID, EventDate from Table1 where EventID is null and CompanyID is null and EventDate = 'Nov 12 2007'.
This query will, obviously, always return empty since it explicitly checks for "EventID is null and CompanyID is null" which they'll never ever be (EventID is the Primary Key and CompanyID doesn't allow NULLs).
So my question is: Do I need to specify each and every field in my Find-method? Like DataRepository.Table1Provider.Find("EventID not is null, CompanyID not is null, EventDate = '" + DateTime.Now + "'") or am I doing something completely wrong here?
Thanks in advance,
/DonRex.