Skip to content

Instantly share code, notes, and snippets.

@ArtemyB
Created April 13, 2023 08:43
Show Gist options
  • Save ArtemyB/07013dfb7bf4b526c1b8dd167b869921 to your computer and use it in GitHub Desktop.
Save ArtemyB/07013dfb7bf4b526c1b8dd167b869921 to your computer and use it in GitHub Desktop.
type Claim = { Name: string; Value: string }
type Mapping = { Group: string; Roles: string list }
let mapping = [
{ Group = "aaa"; Roles = [ "Admin" ] }
{ Group = "ccc"; Roles = [ "King" ] }
{ Group = "uuu"; Roles = [ "User" ] }
]
let groups = [ "aaa"; "bbb"; "ccc" ]
let joinedList =
query {
for group in groups do
join mapping in mapping on (group.ToUpperInvariant() = mapping.Group.ToUpperInvariant())
select mapping
} |> Seq.toList
// The same query in C# LINQ:
// var joined =
// (
// from adGroup in groups
// join mappingRecord in mapping
// on adGroup.ToUpperInvariant() equals mappingRecord.Group.ToUpperInvariant()
// select mappingRecord
// ).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment