Closed oslboreal closed 2 years ago
Maybe the problem could be that I'm not having POCO classes in the same project I installed DapperExtensions. Is there a way to solve that?
Note: I'm not able to edit the database scheme 👎 I'm dealing with a preexistent database (that really sucks).
Thank you a lot again!
Quick questions:
POCO
specifically (eg: ClassMap<User>
)?DapperExtensions.DapperExtensions.SetMappingAssemblies([...]);
?Yes I tried, but it is still not working. Do you have a repository with your implementation? Maybe I could figure out what's wrong with my code. Anyway I tried A LOT. Thank you!
I don't, sorry. I only have internal repos.
For me the structure is as follows:
src/Runner (This is a Desktop executable with Winforms)
src/Web (The web side of the app)
data/Poco
data/Poco.Mappings
On the Web
project (MVC
) I have, on the ctor
of Startup
:
var assemblies = new[]
{
typeof(SomePoco_Mapper).Assembly
};
DapperExtensions.DapperExtensions.SetMappingAssemblies(assemblies);
And on this example, SomePoco_Mapper
would be:
public class SomePoco_Mapper : ClassMapper<SomePoco>
{
//...
}
Nothing else. That also works for desktop. On the Program.cs
of the Runner
I have the same configuration.
Everything just works there.
Dapper
: 2.0.123
DapperExtensions
: 1.7.0
I never used the way you're trying to use.
Did you try to put this in your startup.cs
services.AddAutoMapper(typeof(Startup));
You'll need to add AutoMapper package
Here's how I handled it:
Because it has synchronous and asynchronous,so you have to set both.
DapperExtensions.DapperExtensions.DefaultMapper = typeof(BetaDapperMapper<>); DapperExtensions.DapperExtensions.SetMappingAssemblies(new List<Assembly>(){typeof(BetaDapperMapper<>).Assembly}); DapperExtensions.DapperAsyncExtensions.DefaultMapper = typeof(BetaDapperMapper<>); DapperExtensions.DapperAsyncExtensions.SetMappingAssemblies(new List<Assembly>() { typeof(BetaDapperMapper<>).Assembly });
I want to use System.ComponentModel.DataAnnotations [table()] [column()] [notmapped()]
If you are using both, Sync and Async you may set them both. True.
I've been trying to use a custom mapper for my domain entities, I have two different projects, one for domain entities called "Domain" and the last one "Infrastructure" in wich I have my repositories.
Infrastructure has his own DependencyInjection class wich is called in my application Startup.cs file.![image](https://user-images.githubusercontent.com/21184588/146582885-07696370-d508-4548-b165-fe7212bb9b38.png)
I've created a mapper class following the instructions I've found in the documentation.![image](https://user-images.githubusercontent.com/21184588/146583234-0d9f3f53-b1c6-41e8-a569-7323b8f4e5b2.png)
Then I have defined my Domain entity, called User. (Inside my domain project)![image](https://user-images.githubusercontent.com/21184588/146583100-3adf9cdc-91b8-49fe-93c0-3be931d74aba.png)
Then I use DapperExtensions inside my repository![image](https://user-images.githubusercontent.com/21184588/146583488-080d290f-bc5e-4c50-8b1c-d7f51c13e9ce.png)
But It thrown an exception because the library did'nt find the table "User". So, the library is not applying the configuration I supplied on the startup.
Thank you.