How to write a union with a compound key clause in FSharp expression expressions?

How to write this C # compound with a composite key clause in F #?

join k in DataContext.Catalogs on
   new { id = o.IDENT, v = o.VZ } equals
   new { id = k.IDENT, v = k.VZ }

This is a similar question: group multiple columns in an F # 3.0 query that has not yet been answered. But I cannot believe that it is not easy to write to FSharp.

thank

+5
source share
1 answer

Use tuples containing the required key fields:

query {
  for o in DataContext.OTable do
  join k in DataContext.Catalogs on
   ((o.IDENT, o.VZ) = (k.IDENT, k.VZ))
  select (o.IDENT, k.VZ)
}

Please note: you cannot create an anonymous type with named fields in F #, as in C #. Tuples are probably the closest and most idiomatic translation. See Tomas answer here .

+9
source

All Articles