timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

Enum on complex type not detected #17

Closed JonathanHiggs closed 9 years ago

JonathanHiggs commented 9 years ago

I have an enum on a complex type that isn't getting found

timabell commented 9 years ago

Patches welcome ;-)

JonathanHiggs commented 9 years ago

Mostly there with:

from entity in metadata.GetItems<ComplexType>(DataSpace.OSpace)
from property in entity.Properties
where property.IsEnumType
select new EnumReference
{
    ReferencingTable = GetTableName(metadata, GetEntity(metadata, entity)),
    ReferencingField = String.Format("{0}_{1}", entity.Name, property.Name),
    EnumType = objectItemCollection.GetClrType(property.EnumType)
}

It is just getting the ReferencingField name that I am not sure how to get. Any pointers?

timabell commented 9 years ago

I'll have a look when I get a chance, good work :-)

timabell commented 9 years ago

I've done what I can for now but have run out of spare time. I've left some notes in the branch's code on what to look into next; and you can see the test is still failing. Currently GetTableName is returning null for complex types so they are just ignored, so there's still no actual exception.

timabell commented 9 years ago

I have a branch https://github.com/timabell/ef-enum-to-lookup/tree/complex-types-take-2 that basically works if you haven't aliased any of the columns. I need to deal with issue #19 before I can include this in a release as I suspect aliases will be more common for complex types, and if people have a complex type that would previously have been ignored this would be a breaking change.

timabell commented 9 years ago

Released in 1.5.0-beta. Please test this pre-release package and report any issues https://www.nuget.org/packages/ef-enum-to-lookup/1.5.0-beta Thanks

Installing pre-release packages: http://blog.iwanek.eu/how-to-install-prerelease-nuget-package/