Finbuckle.MultiTenant icon indicating copy to clipboard operation
Finbuckle.MultiTenant copied to clipboard

Make ITenantInfo's Id type a generic

Open julesrx opened this issue 3 years ago • 7 comments

Change ITenantInfo's Id type to a generic to allow for more flexibility when implementing the library. This would help since here, even if the Id is a number in the tenant store or the database, it needs to be converted into a string.

Essentially, change this :

public interface ITenantInfo
{
    string? Id { get; set; }
}

To this :

public interface ITenantInfo<TKey>
{
    TKey? Id { get; set; }
}

And keep the default TenantInfo to a string :

public class TenantInfo : ITenantInfo<string>

This is a big breaking change though, with lots of refactoring to do 😐. (realized this could be a duplicate of #365)

julesrx avatar Oct 18 '22 21:10 julesrx

Hi, yes this on my todo list. And I plan to tackle it soonish.

AndrewTriesToCode avatar Oct 19 '22 04:10 AndrewTriesToCode

Should the interface be this instead? Feels wrong to force it to be nullable as in the OP.

public interface ITenantInfo<TId>
{
    TId Id { get; set; }
}

You would then use it like this for compatibility:

public class TenantInfo : ITenantInfo<string?>

Alternatively, you could also force the ID to be immutable, and never null (as I would personally expect) and have a huge refactor 😅

public interface ITenantInfo<TId>
    where TId : notnull
{
    TId Id { get; init; }
}

domn1995 avatar Jan 06 '23 06:01 domn1995

It would be a great improvement if we could change the type to something other than a string. I've been shouted at today (not really, but almost) that the TenantId is a string in our SQL database. I'm inclined to agree, so I was wondering if there are any plans to work on this soon?

hbulens avatar Mar 07 '23 16:03 hbulens

I am working on it but it's nontrivial and will cause breaking changes because some areas assume a string... great thinking on my part years ago. I do plan to include this soon. I'm wrapping it up with a few other breaking changes for a single major release bump.

AndrewTriesToCode avatar Mar 10 '23 07:03 AndrewTriesToCode