Skip to content

Simplify Entity invocation: support Entity<T>(repository, tableName) without requiring subclassing/filter args #24

Description

@lukaferlez

Context

From review discussion on PR #22 (docs PR):
#22 (comment)

Declaring an entity is not necessary, the simplest version is

var entity = new Entity<Identity>(repository, new Table<Identity>("I"));

Why would one want to declare the IdentityEntity? To avoid using complicated type names such as Entity<Identity, IdentityFilter, DbQueryOptions> all over the place when things get extended. The more complicated version should be noted in the usage.md with the reasons.

We need a task to further simplify this to Entity<Identity>(repository, string tableName), as well.

Task

Add a further-simplified Entity<TModel> constructor overload that takes a plain
string tableName instead of requiring the caller to construct a Table<TModel>
themselves, e.g.:

var entity = new Entity<Identity>(repository, "I");

This should be equivalent to today's:

var entity = new Entity<Identity>(repository, new Table<Identity>("I"));

i.e. internally construct the Table<TModel> from the given table name so callers
don't need to know about Table<T> for the common case.

Acceptance criteria

  • New constructor overload on Entity<TModel> (and/or the appropriate base
    Entity<TModel, TFilter, TOptions> constructor chain) accepting (repository, string tableName).
  • Existing (repository, Table<TModel>) constructor remains available for cases
    needing more control (custom schema, quoting, etc.).
  • Add/adjust tests covering the new string-based constructor.
  • Update docs/USAGE.md (and README quick start if applicable) to show the
    simplest form first, and note the Table<T> overload as the "more complicated
    version" for advanced cases, per the reasoning in the linked review comment.

Closes/relates to the docs feedback in PR #22.

Metadata

Metadata

Assignees

Labels

agent-okAgent may work on this issueagent-pr-openAgent has opened a draft PR for this issueagent-smallSmall, well-scoped task suitable for autonomous agent

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions