automapper-5

Automapper - How to map from source child object to destination

馋奶兔 提交于 2020-07-08 14:53:48
问题 I am trying to map from a child object of source to destination(as parent object). Source Model: public class SourceBaseResponse<T> where T : new() { public string Type { get; set; } public string Id { get; set; } public T Attributes { get; set; } } For my example I am using T to be of type SourceAssignment public class SourceAssignment { public string Id { get; set; } public string Email { get; set; } public string EmployeeId { get; set; } public string FirstName { get; set; } public string

EF OData MySql Unknown column 'Project3.x' in 'where clause'

南楼画角 提交于 2019-12-23 02:37:06
问题 I'm using OData V4, EF6 and MySql 5.6/5.7 With below models and tables. I get the result of the Application resource fine with this call odata/Applications but I get this error when I expand on roles, as follows odata/Applications?$expand=roles. Error: An error occurred while executing the command definition. See the inner exception for details. Unknown column 'Project3.ApplicationId' in 'where clause' I know it's something with mapping, but I can't see what. public class Role { public int Id

Mapper not initialized, When Use ProjectTo()

我们两清 提交于 2019-12-18 19:01:33
问题 I Use Automapper 5.2.0 In My Project. When I Use ProjectTo() In Code Get This Error: Mapper not initialized. Call Initialize with Appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance. Service Code public async Task

Mapper not initialized, When Use ProjectTo()

不问归期 提交于 2019-12-18 19:00:07
问题 I Use Automapper 5.2.0 In My Project. When I Use ProjectTo() In Code Get This Error: Mapper not initialized. Call Initialize with Appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance. Service Code public async Task

Setting up Automapper 5.1

我是研究僧i 提交于 2019-12-17 22:59:45
问题 I am having trouble following the wiki in this instance. I wanted to use Automapper 5.2. I cannot find a simple end for end example that shows a solid configuration with context. By context I mean where do you put the config files and whats the difference between static and instance api? I checked out the DNRTV download but it deals with the 1.0 version. How do you set this package up? I have a model called Client as below. public class Client : IEntityBase { public Client() { Jobs = new List

map configuration or unsupported mapping

跟風遠走 提交于 2019-12-12 02:30:00
问题 I have two types. One in the business layer: namespace Business { public class Car { private int _id; private string _make; private string _model; public int id { get { return _id; } set { _id = value; } } public string make { get { return _make; } set { _make = value; } } public string model { get { return _model; } set { _model = value; } } } } and the other in the Data layer (Entity Framework): namespace Data { using System; using System.Collections.Generic; public partial class Car {

How to use Automapper 5?

强颜欢笑 提交于 2019-12-12 01:46:21
问题 I am new to Automapper. With below links, I am trying to understand it in action. http://automapper.org/ https://lostechies.com/jimmybogard/2016/01/21/removing-the-static-api-from-automapper/ I am using its Automapper v 5.2.0 Here is my stuff. https://codepaste.net/xph2oa class Program { static void Main(string[] args) { //PLEASE IGNORE NAMING CONVENTIONS FOR NOW.Sorry!! //on Startup AppMapper mapperObj = new AppMapper(); mapperObj.Mapping(); DAL obj = new DAL(); var customer = obj

Automapper to update an existing object as opposed to creating a new one [duplicate]

烂漫一生 提交于 2019-12-11 05:14:54
问题 This question already has answers here : Automapper: Update property values without creating a new object (3 answers) Closed last year . Is there any way to use Automapper 5.1.1 to update an existing object as opposed to creating a new one. For example we have a Customer entity and a CustomerViewModel . We would like to update an existing Customer with the CustomerViewModel field values. Would greatly appreciate your assistance. 回答1: It is not adviced to use Automapper to map a model to your

Using Automapper to Copy Properties from a Dynamic

谁都会走 提交于 2019-12-10 20:58:42
问题 I have a dynamic object (actually, a JObject, from JSON.NET) being built dynamically from JSON. I want to have its properties copied to an existing object. The properties from the dynamic object should exist in the target object's type, if not, it's ok to have an error. I am looking at Automapper, latest version, for this. I tried to create a map from JObject to the proper type, but I don't think it'll work because the properties in the JObject are stored in an internal dictionary. Is this

Automapper v5 Ignore unmapped properties

时间秒杀一切 提交于 2019-12-09 16:30:46
问题 Previously when I used Automapper v3.x ignoring unmapped properties could be done by simply adding a .IgnoreUnmappedProperties() extension which looked like this public static class AutoMapperExtensions { public static IMappingExpression<TSource, TDestination> IgnoreUnmappedProperties<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression) { var typeMap = Mapper.FindTypeMapFor<TSource, TDestination>(); if (typeMap != null) { foreach (var unmappedPropertyName in