-
Notifications
You must be signed in to change notification settings - Fork 128
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
Enhancement: TypeMapper for MSSQL (Udt and Spatial) #1023
Comments
FYI: We will soon release the last 2 months update but this may not be a part of it. This will be a part of the next release after that release. |
This is a note, the target fix to this is for the user to be able add the following code. FluentMapper
.Type<Microsoft.SqlServer.Types.SqlGeography>()
.PropertyValueAttributes(new[]
{
new SqlDbTypeAttribute(SqlDbType.Udt),
new UdtTypeNameAttribute("Geography")
}); EDIT: Also, via the actual PropertyValueAttributeMapper. PropertyValueAttributeMapper
.Add<Microsoft.SqlServer.Types.SqlGeography>(e =>
new[]
{
new SqlDbTypeAttribute(SqlDbType.Udt),
new UdtTypeNameAttribute("Geography")
}); |
Referencing #1059 |
The fixes to this will be available on the next version > RepoDB v1.12.10. |
I tried it, but it doesn't work. Current call will fail: FluentMapper
.Type<Microsoft.SqlServer.Types.SqlGeography>()
.PropertyValueAttributes<Microsoft.SqlServer.Types.SqlGeography>(new PropertyValueAttribute[]
{
new SqlDbTypeAttribute(SqlDbType.Udt),
new UdtTypeNameAttribute("Geography")
});
//note, that you need to add the type Microsoft.SqlServer.Types.SqlGeography two times. The problem can be found in TypeMapFluentDefinition.cs//this is the current line. It calls itself (infinite loop, stack overflow):
public TypeMapFluentDefinition<TType> PropertyValueAttributes<T>(IEnumerable<PropertyValueAttribute> attributes) =>
PropertyValueAttributes<T>(attributes);
//possible solution, add force-parameter and set it to false
public TypeMapFluentDefinition<TType> PropertyValueAttributes<T>(IEnumerable<PropertyValueAttribute> attributes) =>
PropertyValueAttributes<T>(attributes, false);
//also I think the generic type T isn't necessary
public TypeMapFluentDefinition<TType> PropertyValueAttributes(IEnumerable<PropertyValueAttribute> attributes) =>
PropertyValueAttributes(attributes, false);
public TypeMapFluentDefinition<TType> PropertyValueAttributes(IEnumerable<PropertyValueAttribute> attributes, bool force) =>
PropertyValueAttributes(typeof(TType), attributes, force);
//with these changes, you can write
FluentMapper
.Type<Microsoft.SqlServer.Types.SqlGeography>()
.PropertyValueAttributes(new PropertyValueAttribute[]
{
new SqlDbTypeAttribute(SqlDbType.Udt),
new UdtTypeNameAttribute("Geography")
}); |
Glad that it is still alpha and not yet beta so this kind of exception can be captured :) |
Hello Mike, FluentMapper
.Type<Microsoft.SqlServer.Types.SqlGeography>()
.PropertyValueAttributes<Microsoft.SqlServer.Types.SqlGeography>(new PropertyValueAttribute[]
{
new SqlDbTypeAttribute(SqlDbType.Udt),
new UdtTypeNameAttribute("Geography")
}, false); |
For User definied Types (Udt) a general TypeMapper for MSSQL would be nice to have.
Example
For Spatial-Types (e.g. SqlGeography) I use dotMorten's Microsoft.SqlServer.Types. With no additional configuration, you can query spatial-data. Doing Updates or Inserts, you have to define somethings for each property:
The text was updated successfully, but these errors were encountered: