Non equijoins using LINQ and F #

I am trying to join two tables using LINQ and F # using a larger statement. This question is essentially the same as the query here , but using F # instead of C #.

In my case, I have two tables in the SQL Server database: intervals and dates , both of which have the start_time and end_time fields .

I need to perform the non-equivalence of these two tables by matching the start and end times of each table. I tried to do it 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 expression expr, where is =, =?,? = or? = ?.

+4
2

cross-join/selectmany ( fors) where.

.

let results = query {
    for i in dc.intervals do 
    for t in dc.timelines do
    where (t.start_time > i.start_time && t.start_time < i.end_time)
    select (i, t)
}
+3

F # LINQ docs , # docs ( ) , join equijoins. , , . @ildjarn .

+4

Source: https://habr.com/ru/post/1542189/


All Articles