-
Notifications
You must be signed in to change notification settings - Fork 226
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
Comments
Once this is complete and the flag is set will it allow generation into separate files? |
Hi @revbones-duplicate Yes it will |
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]");
}; |
That example made no sense to me.
I want each poco entity class to derive IDLEntity.
How would I modify the tt script to do this
Sent: Friday, November 10, 2023 at 10:20 AM
From: "Simon Hughes" ***@***.***>
To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" ***@***.***>
Cc: "stevensrf11" ***@***.***>, "Mention" ***@***.***>
Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
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]");
};
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I understand this from a former post
Func<Table, string> WritePocoBaseClasses = t =>
{
if (t.NameHumanCase== "Contact" || t.NameHumanCase== "Customer")
{
var r = new BaseClassMaker("BaseClass");
return r.ToString();
}
}
But I have no clue what any of that code you shown below does.
What does this do and why would I want a new list?
Does creating these new variable mess up anything or change anying that works already?
why the use of the hard coded string what do the hard code string mean?
var tracking = new List<string> { "createdby", "createdon", "modifiedby", "modifiedon" }; var replicate = new List<string> { "uniqueid", "hrid"}; var replicate = new List<string> { "uniqueid", "hrid"};
Is this suppose to create two base classes based for a table that is named by one if the string is tracking and replicate variables?
if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase))) table.BaseClasses = " : TrackingEntity";
if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase))) table.BaseClasses = " : ReplicateEntity";
Sent: Friday, November 10, 2023 at 10:20 AM
From: "Simon Hughes" ***@***.***>
To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" ***@***.***>
Cc: "stevensrf11" ***@***.***>, "Mention" ***@***.***>
Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
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]");
};
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Ok I got it.
I see all I have to do is set table.BaseClasses equal to a class that derives from the interface.
Thanks
Steven
Sent: Friday, November 10, 2023 at 10:20 AM
From: "Simon Hughes" ***@***.***>
To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" ***@***.***>
Cc: "stevensrf11" ***@***.***>, "Mention" ***@***.***>
Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
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]");
};
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Settings.UpdateTable = delegate(Table table)
{
table.BaseClasses = " : IDLEntity";
}; |
Thank you
… Sent: Friday, November 10, 2023 at 7:31 PM
From: "Simon Hughes" ***@***.***>
To: sjh37/EntityFramework-Reverse-POCO-Code-First-Generator ***@***.***>
Cc: stevensrf11 ***@***.***>, Mention ***@***.***>
Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
@stevensrf11
```cs
Settings.UpdateTable = delegate(Table table)
{
table.BaseClasses = " : IDLEntity";
};
```
--
Reply to this email directly or view it on GitHub:
#789 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Add an option to create a poco interface.
The {{moustache}} template will be something like this:
The text was updated successfully, but these errors were encountered: