RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Question: Does RepoDB supports C# 9s Records?

Open keithn opened this issue 4 years ago • 5 comments

does repoDB support Records?

also, all the current documentation uses the word "record" to refer to "database" records, which perhaps should be changed to "row"/"rows" as it now conflicts with the first class concept in C# and gives erroneous search results.

keithn avatar Jan 11 '21 02:01 keithn

Yes, it supports it both C#/F# and also the immutables.

mikependon avatar Jan 11 '21 05:01 mikependon

Just a follow-up question: Can the attributes like PrimaryAttribute applied to a constructor parameter too? Example:

public record Test([Primary] Guid Id, string Name);

fubar-coder avatar Jan 18 '22 18:01 fubar-coder

Unfortunately, it is not possible. The only thing you can work around with this is to place the Primary attribute into the equivalent property of the ctor argument.

mikependon avatar Jan 18 '22 21:01 mikependon

But, since you are using the record type, then it is kind of impossible. We will assess and look at this as part of our enhancements.

mikependon avatar Jan 18 '22 21:01 mikependon

This is my current code:

public record Test(Guid Id, string Name)
{
    [Primary]
    public Guid Id { get; } = Id;
}

This works as expected and is fine as a workaround (at least for me)!

fubar-coder avatar Jan 18 '22 22:01 fubar-coder