automapper

Mapping one type to another

﹥>﹥吖頭↗ 提交于 2021-01-07 01:36:15
问题 Let's say I have the following types. type Contract struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` ContractTypeId int `json:"contract_type_id" gorm:"column:contract_type_id"` } type ContractModel struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` } I have a SQL query using gorm to scan results

Mapping one type to another

只谈情不闲聊 提交于 2021-01-07 01:35:19
问题 Let's say I have the following types. type Contract struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` ContractTypeId int `json:"contract_type_id" gorm:"column:contract_type_id"` } type ContractModel struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` } I have a SQL query using gorm to scan results

AutoMapper Custom Resolver asking for optional parameters in constructor

一个人想着一个人 提交于 2021-01-04 08:38:49
问题 I am having some issues with a custom resolver in AutoMapper. I am passing in a interface to the constructor of my repository but i keep getting the following error: Type needs to have a constructor with 0 args or only optional args Parameter name: type I can get around it by creating a parameter-less constructor and hard coding the concrete implementation of my repo in there, but i want to inject it. My Resolver: public class OptionGroupProjectionResolver : ValueResolver<Product, List

How to take OData Queryable Web API endpoint filter and map it from DTO object?

爷,独闯天下 提交于 2021-01-04 03:12:40
问题 I have a simple Web API endpoint which can accept incoming OData queries: public IActionResult GetProducts(ODataQueryOptions<ProductDTO> options) { var results = DomainLayer.GetProducts(options); return Ok(results); } I specifically want to be able to query against ProductDTO objects and to be able to filter or sort against the properties of the DTO representation. My design issue is that I want to take advantage of the filter parsing/applying logic of the OData library but I don't want to

How to take OData Queryable Web API endpoint filter and map it from DTO object?

跟風遠走 提交于 2021-01-04 03:07:12
问题 I have a simple Web API endpoint which can accept incoming OData queries: public IActionResult GetProducts(ODataQueryOptions<ProductDTO> options) { var results = DomainLayer.GetProducts(options); return Ok(results); } I specifically want to be able to query against ProductDTO objects and to be able to filter or sort against the properties of the DTO representation. My design issue is that I want to take advantage of the filter parsing/applying logic of the OData library but I don't want to

Automapper issue with identityserver4 - MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'

浪尽此生 提交于 2021-01-02 05:43:25
问题 I using last version of IdentityServer 4 Issue / Steps to reproduce the problem Creating a new blazor webassembly app I scaffolded all the Identities files and customized and custom ApiAuthorizationDbContext for blazor webassembly Install Automapper v10 and AutoMapper.Extensions.Microsoft.DependencyIn v8.0.1 when I run project, in-browser give me 500 error : AuthenticationService.js:44 GET https://localhost:5001/connect/authorize?client_id=Web.Client&redirect_uri=https%3A%2F%2Flocalhost

Automapper issue with identityserver4 - MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'

心已入冬 提交于 2021-01-02 05:42:18
问题 I using last version of IdentityServer 4 Issue / Steps to reproduce the problem Creating a new blazor webassembly app I scaffolded all the Identities files and customized and custom ApiAuthorizationDbContext for blazor webassembly Install Automapper v10 and AutoMapper.Extensions.Microsoft.DependencyIn v8.0.1 when I run project, in-browser give me 500 error : AuthenticationService.js:44 GET https://localhost:5001/connect/authorize?client_id=Web.Client&redirect_uri=https%3A%2F%2Flocalhost

Automapper issue with identityserver4 - MissingMethodException: Method not found: '!!0 AutoMapper.IMapper.Map(System.Object)'

余生颓废 提交于 2021-01-02 05:42:15
问题 I using last version of IdentityServer 4 Issue / Steps to reproduce the problem Creating a new blazor webassembly app I scaffolded all the Identities files and customized and custom ApiAuthorizationDbContext for blazor webassembly Install Automapper v10 and AutoMapper.Extensions.Microsoft.DependencyIn v8.0.1 when I run project, in-browser give me 500 error : AuthenticationService.js:44 GET https://localhost:5001/connect/authorize?client_id=Web.Client&redirect_uri=https%3A%2F%2Flocalhost

Automapper map to nullable DateTime property

核能气质少年 提交于 2020-12-26 07:47:46
问题 using Automapper 3.1.1 I can not compile this map: Mapper.CreateMap<Domain.DomainObjects.Entities.Patient, PatientDto>() .ForMember(x => x.Deleted, opt => opt.MapFrom(input => input.Deleted.HasValue ? new DateTime(input.Deleted.Value.Ticks, DateTimeKind.Utc) : null )); Error: Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'DateTime' Entity: public class Patient : Entity { // more properties public virtual DateTime? Deleted {

Trying to add AutoMapper to .NetCore1.1 - not recognising services.AddAutoMapper()

人走茶凉 提交于 2020-12-24 07:12:08
问题 I've installed the following Nuget packages into my project: Automapper AutoMapper.Extensions.Microsoft.DependencyInjection I have added the line to ConfigureServices in Startup.cs . public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); // . . . services.AddAutoMapper(); } I'm still getting a red line under services.AddAutoMapper() . It says: The Call is ambiguous between the following methods or properties: ServiceCollectionExtensions