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

Ability to fetch db names for documents/aggregates from marten options. #3127

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

elexisvenator
Copy link
Contributor

Closes #3125

As per the above issue, the usage is as follows:

IQuerySession session;

var schema = session.DocumentStore.Options.Schema;

var a = schema.DatabaseSchemaName;  // "public"
var b = schema.EventsSchemaName;    // "public" // can be different

var c = schema.For<User>();            // "public.mt_doc_user"
var d = schema.For<UserProjection>();  // "public.mt_doc_userprojection"
var e = schema.ForStreams();           // "public.mt_streams"
var f = schema.ForEvents();            // "public.mt_events"
var g = schema.ForEventProgression();  // "public.mt_event_progression"

var h = schema.For<User>(qualified: false);            // "mt_doc_user"
var i = schema.For<UserProjection>(qualified: false);  // "mt_doc_userprojection"
var j = schema.ForStreams(qualified: false);           // "mt_streams"
var k = schema.ForEvents(qualified: false);            // "mt_events"
var l = schema.ForEventProgression(qualified: false);  // "mt_event_progression"

I have updated the advanced sql examples to fetch table names this way, and have added a section to the documentation describing the functionality.

/// Otherwise only the table name is returned.
/// </param>
/// <returns>The name of <typeparamref name="TDocument"/> in the database.</returns>
string For<TDocument>(bool qualified = true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add an overload that accepts Type as a parameter? I could see a scenario where someone wants to loop through an array of types to run sql against multiple tables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that in a bit. It's almost inevitable that using Method means you'll eventually want Method(Type)

@jeremydmiller jeremydmiller merged commit a21feef into JasperFx:master Apr 10, 2024
11 checks passed
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

Successfully merging this pull request may close these issues.

Expose way to get the db table names of documents and aggregates
3 participants