object-object-mapping

Restkit to-many relationship append to set instead of setting a new set

泪湿孤枕 提交于 2019-12-05 10:18:06
I have a iOS Restkit related question. I have a parent-child relationship data coming from a remote server and map those object to a NSManagedObject object with Restkit. The problem that I am currently having is every request to the server always wipe out the "child" relationship and replace it with the new data coming from the server. Is there a way to avoid those and append the new child instead? For example: I have a classic Category --> Products relationship. {"categories": [ { "cat_id": "1", "cat_title": "category 1", "cat_tag": 1, "product": [ { "prod_id": "1", "prod_name": "product 1",

MapStruct: Mapping 2 objects to a 3rd one

…衆ロ難τιáo~ 提交于 2019-12-04 18:26:26
问题 I have Object1 and Object2. Now, I want to map object3, with attributes from 1 & 2. Say, I have 2 object: 1. User: {first_name, last_name, id} 2. Address: {street, locality, city, state, pin, id} Now, with these, I want to map that in User_View: {firstName, lastName, city, state}. Where, first_name & last_name will be from User object and city & state from Address object. Now, my question is, how to do that? However, currently, I'm doing like this @Mapper public abstract class UserViewMapper

Is there a suggested pattern for using LINQ between the Model & DataAccess Layers in a DDD based Layered Architecture

我的梦境 提交于 2019-12-02 20:55:59
I've been reading Tim McCarthy's awesome book on DDD in .NET . In his example application though, his underlying data access is using SqlCE and he's handcrafting the SQL inline. I've been playing with some patterns for leveraging Entity Framework but I've gotten stuck on how exactly to map the IRepository linq queries to the underlying data access layer. I have a concrete repository implementation called. public EFCustomerRepository : IRepository<DomainEntities.Customer> { IEnumerable<DomainEntities.Customer> GetAll( Expression<Func<DomainEntities.Customer, bool>> predicate) { //Code to access

How to map JAXB elements annotated with @XMLSeeAlso using mapStruct?

痴心易碎 提交于 2019-12-01 13:57:05
I'm trying to map a bean which has some JAXB elements like @XmlSeeAlso, @XmlElement, @XmlSchemaType as properties for that class. @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Customer") @XmlSeeAlso({PersonalCustomer.class, BusinessCustomer.class}) public class Customer extends Role { @XmlElement(name = "AMLLineOfBusiness") private LOB amlLineOfBusiness; // 50 odd properties //some properties with XmlElement/XmlSchemaType // getters and setters } @Mapper public interface CustomerMapper { PersonalCustomer personcalCustomerToPersonalCustomer(PersonalCustomer pc); @Mappings({ /*Several

How to map JAXB elements annotated with @XMLSeeAlso using mapStruct?

流过昼夜 提交于 2019-12-01 13:09:17
问题 I'm trying to map a bean which has some JAXB elements like @XmlSeeAlso, @XmlElement, @XmlSchemaType as properties for that class. @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Customer") @XmlSeeAlso({PersonalCustomer.class, BusinessCustomer.class}) public class Customer extends Role { @XmlElement(name = "AMLLineOfBusiness") private LOB amlLineOfBusiness; // 50 odd properties //some properties with XmlElement/XmlSchemaType // getters and setters } @Mapper public interface

Automapper - Bestpractice of mapping a many-to-many association into a flat object

落花浮王杯 提交于 2019-11-30 15:07:46
I have two entities: Employee and Team . What I want is an EmployeeForm that has the Name of the Team . How can I achieve this using AutoMapper ? My current "solution" is the following: Mapper.CreateMap<Employee, EmployeeForm>() .ForMember(dest => dest.TeamName, opt => opt.MapFrom(x => x.GetTeams().FirstOrDefault() != null ? string.Join(", ", x.GetTeams().Select(y=>y.Name)) : "n/a")); In my opinion this is bad readable. What I would like to have is a generic method where I can pass an entity, choosing the collection and saying if collection is null return a default value or otherwise choose

Ignore mapping one property with Automapper

我的梦境 提交于 2019-11-26 17:06:38
I'm using Automapper and I have the following scenario: Class OrderModel has a property called 'ProductName' that isn't in the database. So when I try to do the mapping with: Mapper.CreateMap<OrderModel, Orders>(); It generates an exception : "The following 1 properties on Project.ViewModels.OrderModel are not mapped: 'ProductName' I've read at AutoMapper's Wiki for Projections the opposite case (the extra attribute is on the destination, not in the source which is actually my case ) How can I avoid automapper to make the mapping of this property? smartcaveman From Jimmy Bogard: CreateMap<Foo,

AutoMapper vs ValueInjecter [closed]

一个人想着一个人 提交于 2019-11-26 16:46:58
Everytime I'm looking for AutoMapper stuff on StackOverflow, I'm reading something about ValueInjecter . Can somebody tell me the pros and cons between them (performance, features, API usage, extensibility, testing) ? as the creator of ValueInjecter , I can tell you that I did it because I wanted something simple and very flexible I really don't like writing much or writing lots of monkey code like: Prop1.Ignore, Prop2.Ignore etc. CreateMap<Foo,Bar>(); CreateMap<Tomato, Potato>(); etc. ValueInjecter is something like mozilla with it's plugins, you create ValueInjections and use them there are

AutoMapper vs ValueInjecter [closed]

心已入冬 提交于 2019-11-26 04:56:47
问题 Everytime I\'m looking for AutoMapper stuff on StackOverflow, I\'m reading something about ValueInjecter. Can somebody tell me the pros and cons between them (performance, features, API usage, extensibility, testing) ? 回答1: as the creator of ValueInjecter, I can tell you that I did it because I wanted something simple and very flexible I really don't like writing much or writing lots of monkey code like: Prop1.Ignore, Prop2.Ignore etc. CreateMap<Foo,Bar>(); CreateMap<Tomato, Potato>(); etc.

Ignore mapping one property with Automapper

孤街醉人 提交于 2019-11-26 03:48:51
问题 I\'m using Automapper and I have the following scenario: Class OrderModel has a property called \'ProductName\' that isn\'t in the database. So when I try to do the mapping with: Mapper.CreateMap<OrderModel, Orders>(); It generates an exception : \"The following 1 properties on Project.ViewModels.OrderModel are not mapped: \'ProductName\' I\'ve read at AutoMapper\'s Wiki for Projections the opposite case (the extra attribute is on the destination, not in the source which is actually my case )