Marten.FSharp icon indicating copy to clipboard operation
Marten.FSharp copied to clipboard

Using F# Record types as named parameters

Open TheAngryByrd opened this issue 8 years ago • 1 comments

As of now, you can't use named parameter queries easily from F# because the parameter handler looks for anonymous objects which F# doesn't support.

The code for detecting anonymous types just looks to see if the object has a namespace. You can do this from F# by declaring types in a module only file like

module Parameters

type ByName = {
    name : string
}

but this is not obvious nor optimal.

I have an Stackoverflow question about detecting F# record types from C# at runtime to see if we can maybe add a detection to Marten main. If that's not easy/possible we should consider alternatives.

TheAngryByrd avatar Oct 06 '17 14:10 TheAngryByrd

I did a bit of research and this will work with the existing code (https://github.com/JasperFx/marten/blob/b752e79d473783651a763b18c2dc0f8c52d95816/src/Marten/Util/CommandExtensions.cs#L63) if we can just PR an extension to the detection code. Just have to do it via attribute inspection so as to not introduce the link to FSharp.Core

baronfel avatar Jul 10 '18 02:07 baronfel