valueinjecter

valueinjecter not copying nested properties values

允我心安 提交于 2020-01-25 00:25:28
问题 I have following class: public class Ad { public int Id {get;set;} public string Title { get; set; } public string UrlTitle { get; set; } public LookUp Color {get;set} public LookUp Condition {get;set} public int InsertUserId {get; set;} public DateTime InsertDate {get; set;} } LookUp class is as follows: public class LookUp { public int Id {get;set;} public string Name { get; set; } public int InsertUserId {get; set;} public DateTime InsertDate {get; set;} } Then I have ViewModels for these

Using ValueInjecter to map between objects with different property names

风格不统一 提交于 2019-12-31 22:32:24
问题 How do I map a property from an object to another object with a different property name? I have a Product class that looks like this: public class Product : IEntity { public int Id { get; set; } public string Name { get; set; } } And the view model looks like: public class ProductSpecificationAddViewModel { public int ProductId { get; set; } public string ProductName { get; set; } } I need to do the following mapping: Product.Id => ProductSpecificationAddViewModel.ProductId Product.Name =

Mapping LinqToEntities join to ViewModel

大城市里の小女人 提交于 2019-12-25 05:18:12
问题 I have the following Models and ViewModels (edited for brevity): Order Model: OrderId ShippingAddressId ..... Address Model: AddressId ..... OrderViewModel: Some Property from Order Model and Address Model how can inner join two tables and map to a viewmodel ? var query= from o in ctx.Orders join addr in ctx.Addresses on o.ShippingAddressId equals addr.AddressId select new OrderViewModel.InjectFrom(o) .InjectFrom(addr) as OrderViewModel; this code doesn't work . 回答1: You need to first

ValueInjecter: how to ignore some properties while performing .InjectFrom<UnflatLoopValueInjection>(data)?

廉价感情. 提交于 2019-12-23 15:42:21
问题 I'm using ValueInjecter instead of AutoMapper. I'm trying to perform unflattening operation using .InjectFrom<UnflatLoopValueInjection>(model) It works, but I would also like to specity some properties to ignore during the unflattening operation, for example writing something like: .InjectFrom<UnflatLoopValueInjection>(new IgnoreProperties("Prop1", "Prop2"), model) or .InjectFrom<UnflatLoopValueInjection>(model).IgnoreProperties("Prop1", "Prop2") Any ideas? 回答1: With the latest version of Omu

Do I have to Load/Get an entity before SaveOrUpdate in Nhibernate?

删除回忆录丶 提交于 2019-12-23 08:08:21
问题 in my ASP.NET MVC application I've separated the domain model from the view model. I transform my entity in a viewmodel object so I can "feed" my views with only the data needed (I used valueinjecter for this purpose). During the save process my controller gets back the viewmodel object, transforms it into a domain model entity and try to persist it with SaveOrUpdate. I've noticed that if I try to update an existing record, Nhibernate considers it as a new object and forces an INSERT, even if

Steps to map classes using ValueInjector

被刻印的时光 ゝ 提交于 2019-12-13 06:06:23
问题 Quickly getting to the problem the mapping does not occur for the following code. Could someone explain why? or what i should do for the mapping to occur? var parent = new Parent(); parent.ChildOne.Add(new ChildOne() { Name = "Child One" }); parent.ChildTwo.Add(new ChildTwo() { Name = "Child Two" }); AnotherParent anotherParent = new AnotherParent(); anotherParent.InjectFrom<LoopValueInjection>(parent); Required Class are below Anothher child one public class AnotherChildOne { public string

AutoMapper strings to enum descriptions

て烟熏妆下的殇ゞ 提交于 2019-12-12 10:50:43
问题 Given the requirement: Take an object graph, set all enum type properties based on the processed value of a second string property. Convention dictates that the name of the source string property will be that of the enum property with a postfix of "Raw". By processed we mean we'll need to strip specified characters e.t.c. I've looked at custom formatters, value resolvers and type converters, none of which seems like a solution for this? We want to use AutoMapper as opposed to our own

How do I create a custom value injection to map my entity to my view model? Attempt included

末鹿安然 提交于 2019-12-12 09:57:55
问题 I'm trying to use the ValueInjector (latest version from NuGet) to inject my view model with data from my EntityFramework Code First object. I'll want to do the reverse of this as well, but this is the attempt I'm starting with. I've researched the various mappings and have tried many of them. I haven't found one that does what I need and I think my need is a rather basic one (there are several of these questions on SO and each seems to get a different answer, which is fine.). I've really

ICollectionView throw Entity Framework Attach exception

那年仲夏 提交于 2019-12-11 12:12:10
问题 When i try to save a Object to EF it throw this exception: An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code. Additional information: Attaching an entity of type 'Sistema.DataEntities.Models.Cliente' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph

ValueInjecter - Joins multiple result sets into 1 collection LINQ?

此生再无相见时 提交于 2019-12-11 09:16:32
问题 How do I use ValueInjecter with a LINQ join that joins multiple result sets? For example, this code inject result values into CombinedResult object, but I also want some of errorsAndWarning values into CombinedResult . The properties have the same name: var combined = from result in results.DeferredItems join errorsAndWarning in errorsAndWarnings.DeferredItems on result.MeetingID equals errorsAndWarning.MeetingID select new CombinedResult().InjectFrom(result) as CombinedResult; Thanks. 回答1: