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

Use Type as PropertyPart CustomType instead of only name #347

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void TypeShouldntBeOverwritten()

Convention(x => x.CustomType<int>());

VerifyModel(x => x.Type.Name.ShouldEqual(typeof(CustomUserType).AssemblyQualifiedName));
VerifyModel(x => x.Type.GetUnderlyingSystemType().ShouldEqual(typeof(CustomUserType)));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void EnumsDontGetTypeOverriddenByConventionsIfExplicitlySet()
{
new MappingTester<MappedObject>()
.ForMapping(m => m.Map(x => x.Color).CustomType(typeof(int)))
.Element("class/property[@name='Color']").HasAttribute("type", typeof(int).Name);
.Element("class/property[@name='Color']").HasAttribute("type", typeof(int).AssemblyQualifiedName);
}
}
}
10 changes: 4 additions & 6 deletions src/FluentNHibernate/Mapping/PropertyPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ public PropertyPart CustomType(Type type)
if (typeof(ICompositeUserType).IsAssignableFrom(type))
AddColumnsFromCompositeUserType(type);

return CustomType(TypeMapping.GetTypeString(type));
attributes.Set("Type", Layer.UserSupplied, new TypeReference(type));

return this;
}

/// <summary>
Expand All @@ -206,11 +208,7 @@ public PropertyPart CustomType(string type)
public PropertyPart CustomType(Func<Type, Type> typeFunc)
{
var type = typeFunc.Invoke(member.PropertyType);

if (typeof(ICompositeUserType).IsAssignableFrom(type))
AddColumnsFromCompositeUserType(type);

return CustomType(TypeMapping.GetTypeString(type));
return CustomType(type);
}

private void AddColumnsFromCompositeUserType(Type compositeUserType)
Expand Down