Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Record to be an interface #88

Open
sa2aie opened this issue Mar 26, 2024 · 1 comment
Open

Change Record to be an interface #88

sa2aie opened this issue Mar 26, 2024 · 1 comment

Comments

@sa2aie
Copy link

sa2aie commented Mar 26, 2024

Change the class Record to be an interface instead of a class. This will be a more versatile solution.
This may be a breaking change due to a name change (Record->IRecord) to follow naming conventions.

@Odonno
Copy link
Contributor

Odonno commented Mar 26, 2024

Indeed, having a base class and not an interface have many limitations. Migrating to an IRecord interface seems feasible. I was thinking about this implementation:

public interface IRecord<T>
{
  public T? Id { get; set; }
}

public interface IThingRecord : IRecord<Thing> { }

public interface ITableAndIdRecord<TTable, TId> : IRecord<TId>
{
  public TTable Table { get; set; }
}

IThingRecord and ITableAndIdRecord as the 2 main base types to detect what to do: either use the Thing object directly or create a thing from both Table and Id property.

This will allow to create default interfaces and extend with new ones. Example:

public interface IStringTableAndRecord<TId> : ITableAndIdRecord<string, TId> {}

public interface IStringTableAndStringIdRecord : IStringTableAndRecord<string> {}

I may have oversee things but that could fit your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants