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

Poco interfaces #789

Open
sjh37 opened this issue Jan 23, 2023 · 9 comments
Open

Poco interfaces #789

sjh37 opened this issue Jan 23, 2023 · 9 comments
Assignees

Comments

@sjh37
Copy link
Owner

sjh37 commented Jan 23, 2023

Add an option to create a poco interface.

The {{moustache}} template will be something like this:

{{ClassModifier}} interface I{{NameHumanCaseWithSuffix}}{{#newline}}
{{{#newline}}

{{#each Columns}}
    {{#if OverrideModifier}}override {{/if}}{{WrapIfNullable}} {{NameHumanCase}} { get; {{PrivateSetterForComputedColumns}}set; }{{#newline}}
{{/each}}

{{#if HasReverseNavigation}}
{{#newline}}
{{#each ReverseNavigationProperty}}
    {{Definition}}{{#newline}}
{{/each}}
{{/if}}


{{#if HasForeignKey}}
{{#newline}}
{{#each ForeignKeys}}
    {{Definition}}{{#newline}}
{{/each}}
{{/if}}

{{#if EntityClassesArePartial}}
{{#newline}}
    void InitializePartial();{{#newline}}
{{/if}}
}{{#newline}}
@sjh37 sjh37 self-assigned this Jan 23, 2023
@revbones-dev
Copy link

Once this is complete and the flag is set will it allow generation into separate files?

@sjh37
Copy link
Owner Author

sjh37 commented Jan 30, 2023

Hi @revbones-duplicate Yes it will

@stevensrf11
Copy link

Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?

@sjh37
Copy link
Owner Author

sjh37 commented Nov 10, 2023

Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?

@stevensrf11 Yes it does. Here is an example of adding different base classes depending on name

// Use the following function if you need to apply additional modifications to a table
// Called just before UpdateColumn
Settings.UpdateTable = delegate(Table table)
{
    // To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
    var tracking  = new List<string> { "createdby", "createdon", "modifiedby", "modifiedon" };
    var replicate = new List<string> { "uniqueid", "hrid"};
    if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase)))
        table.BaseClasses = " : TrackingEntity";
    if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase)))
        table.BaseClasses = " : ReplicateEntity";

    // To add attributes
    table.Attributes.Add("[Serializable]");
};

@stevensrf11
Copy link

stevensrf11 commented Nov 10, 2023 via email

@stevensrf11
Copy link

stevensrf11 commented Nov 10, 2023 via email

@stevensrf11
Copy link

stevensrf11 commented Nov 10, 2023 via email

@sjh37
Copy link
Owner Author

sjh37 commented Nov 10, 2023

@stevensrf11

Settings.UpdateTable = delegate(Table table)
{
    table.BaseClasses = " : IDLEntity";
};

@stevensrf11
Copy link

stevensrf11 commented Nov 10, 2023 via email

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

No branches or pull requests

3 participants