سؤال

I am porting a sql query to Simple.Data, the original query is something like:

select a.Field1, a.Field2, b.Field1
from TableA a
join TableB b ON a.KeyField = b.KeyField
where coalesce(b.SomeDate, '1/1/1900') <= getdate()

I've been able to port everything in the query except for that darn coalesce logic:

var currentDate = DateTime.Now;
var result = db.TableA.Query()
    .Join(db.TableB).On(db.TableA.KeyField == db.TableB.KeyField &&
        db.TableB.SomeDate == currentDate)
    .Select(db.TableA.Field1, db.TableA.Field2, db.TableB.Field1);

Any thoughts on how to get the coalesce behavior in there? I've tried using the ?? operator to no avail.

Thanks in advance!

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top