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 · 2 comments
Open

Change Record to be an interface #88

sa2aie opened this issue Mar 26, 2024 · 2 comments

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.

@uherman
Copy link

uherman commented Oct 2, 2024

@Odonno This would be really great!

@sa2aie The breaking change could be avoided by inheriting the interface in the base class i belive.

[Obsolete("Use IRecord interface instead")]
public abstract class Record : IRecord<Thing>
{
    public Thing Id { get; set; }
}

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

3 participants