I am trying to join two tables using LINQ and F# using the greater-than operator. This question is essentially the same as the one asked here, but using F# instead of C#.
In my case I have two tables in an SQL Server database : intervals and timelines, both of which have fields start_time and end_time.
I need to perform a non-equijoin on these two tables, matching the start and end times in each table. I have tried doing this as follows:
let dc = new TypedDataContext()
let qry =
query {
for i in dc.intervals do
join t in dc.timelines on
(t.start_time > i.start_time && t.start_time < i.end_time)
select (i, t)
}
But this predictably fails with the error :
Invalid join relation in 'join'. Expected 'expr expr', where is =, =?, ?= or ?=?.
Although the F# LINQ docs don't mention it, the C# docs (second paragraph) state that joins using the join
keyword are always equijoins. It's probably safe to assume the behavior is consistent across the two languages. @ildjarn suggested a workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With