-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add support for EF models with different schemas #57
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ namespace EfEnumToLookup.LookupGenerator | |
[DebuggerDisplay("{DebuggerDisplay,nq}")] | ||
internal class EnumReference | ||
{ | ||
public string ReferencingTable { get; set; } | ||
public string ReferencingTable { get; set; } | ||
public string ReferencingField { get; set; } | ||
public string ReferencingSchema { get; set; } | ||
public Type EnumType { get; set; } | ||
|
||
// ReSharper disable once UnusedMember.Local | ||
private string DebuggerDisplay | ||
{ | ||
get { return string.Format("EnumReference: {0}.{1} ({2})", ReferencingTable, ReferencingField, EnumType.Name); } | ||
get { return string.Format("EnumReference: {3}.{0}.{1} ({2})", ReferencingTable, ReferencingField, EnumType.Name, ReferencingSchema); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re-order these for readability, or better still convert to the new interpolated string format. I might do a separate commit to use interpolation everywhere |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,15 +53,17 @@ private static IEnumerable<EnumReference> ProcessEdmProperties(IEnumerable<EdmPr | |
// get mapped table name from mapping, or fall-back to just the name if no mapping is set, | ||
// I have no idea what causes Table to be null, and I have no unit test for it yet, but I have seen it. | ||
var table = mappingFragment.StoreEntitySet.Table ?? mappingFragment.StoreEntitySet.Name; | ||
|
||
foreach (var edmProperty in properties) | ||
var schema = mappingFragment.StoreEntitySet.Schema ?? "dbo"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrect indentation - this project uses tabs. Think there's an editorconfig file, if not there should be. http://editorconfig.org/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defaulting to 'dbo' might cause problems with implementing non-sql-server variants (which have been requested). probably better to leave it unqualified if no schema present There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see issue #44 |
||
|
||
foreach (var edmProperty in properties) | ||
{ | ||
if (edmProperty.IsEnumType) | ||
{ | ||
references.Add(new EnumReference | ||
{ | ||
ReferencingTable = table, | ||
ReferencingField = GetColumnName(mappingFragment, edmProperty), | ||
ReferencingSchema = schema, | ||
ReferencingField = GetColumnName(mappingFragment, edmProperty), | ||
EnumType = objectItemCollection.GetClrType(edmProperty.EnumType), | ||
}); | ||
continue; | ||
|
@@ -77,7 +79,8 @@ where nestedProperty.IsEnumType | |
select new EnumReference | ||
{ | ||
ReferencingTable = table, | ||
ReferencingField = GetColumnName(mappingFragment, edmProperty, nestedProperty), | ||
ReferencingSchema = schema, | ||
ReferencingField = GetColumnName(mappingFragment, edmProperty, nestedProperty), | ||
EnumType = objectItemCollection.GetClrType(nestedProperty.EnumType), | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace error - format the file before committing