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

Ignore on Property mappings do not works #13

Closed
rafakwolf opened this issue Dec 3, 2014 · 10 comments
Closed

Ignore on Property mappings do not works #13

rafakwolf opened this issue Dec 3, 2014 · 10 comments
Milestone

Comments

@rafakwolf
Copy link

When i'm trying to make a Crud with this classes and ignore property Friends on Person class mapping, the "ignore" don't works with Dommel.

Error on insert method:
"System.NotSupportedException: The member Friends of type Friend cannot be used as a parameter value".

public class Person{

  public int ID {get;set;}
  public string Name {get;set;}

  public List<Friend> Friends {get;set;}
}

public class Friend{
  public int ID {get;set;}
  public string Name {get;set;} 
}

Thanks in advance

@henkmollema
Copy link
Owner

That exception is thrown by Dapper. It tries to map the Friends property to a sql parameter, which is not supported since it's a complex type.

@rafakwolf
Copy link
Author

OK, but how can i ignore complex types on Insert and Update extension methods from Dommel ?

I made a pull request, please take a look.

Thanks alot!

@henkmollema
Copy link
Owner

This has nothing to do with Dommel. Dapper will try to map the complex type to a sql parameter, whether it exists in the sql query or not. Changing this on the side of Dommel won't fix your issue. I guess your best option is to create a dedicated class for update/insert with Dommel and Dapper.

@rafakwolf
Copy link
Author

With all respect i disagree.
OK, but for what Dommel Mapping exists then ?
If is capable to set the KeyField, then must be capable to set the Ignore fields to, isn't ?

Thanks alot

@henkmollema
Copy link
Owner

I guess you used Dapper.FluentMap.Dommel. This utility provides a mapping from database column names back to C# POCO properties when the result from the query is received. It's also used when Dommel builds SQL queries to map the POCO properties to column names. The Ignore method is only used when mapping query results back to POCO's, not when building sql queries.

@rafakwolf
Copy link
Author

But the column names are used for build queries, isn't ?

@henkmollema
Copy link
Owner

Correct, perhaps it should also be used for that. But that won't fix your issue, since it occurs when Dapper is trying to map it to a database type. See: https://github.com/StackExchange/dapper-dot-net/blob/master/Dapper%20NET40/SqlMapper.cs#L910

@rafakwolf
Copy link
Author

I understand... but when i invoke Connection.Insert()... a query will be constructed correct ? This construction must have ( Not complex types and Not Ignored properties ).

Sorry for the insistence.

Ps.: Did you see my pull request ?

@henkmollema
Copy link
Owner

I think you're right, I'll have to look further into it.

@rafakwolf
Copy link
Author

This library is awesome, i would like to continue contributing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants