automapper

Using AutoMapper with DataTable with missing columns

て烟熏妆下的殇ゞ 提交于 2019-12-11 14:48:56
问题 I'm using AutoMapper to map a datatable to a List. In my scenario, the columns for the datatable may change depending on an outside variable. I can successfully map the datatable to the object w/ the following: AutoMapper.Mapper.CreateMap<IDataReader, Person>(); DataTableReader dtr = myDataTable.CreateDataReader(); List<Person> people = new List<Person>(); people = AutoMapper.Mapper.Map<List<Person>>(dtr); This all works fine. But there are some properties that I need to convert to integer on

AutoMapper - Inheritance preserve reference

南笙酒味 提交于 2019-12-11 14:42:34
问题 I have the following scenario Entity framework classes classes: public class Block { public Guid Id { get; set; } public ICollection<BlockLocation> BlockLocations { get; set; } public BlockType Type { get; set; } } public class BlockLocation { public Guid Id { get; set; } public Guid BlockId { get; set; } public Block Block { get; set; } } And my Domain Entities look like public class Block { public Block(BlockType type = BlockType.None) : this() { Type = type; } private Block() { } public

How do I teach Automapper to map X to IContainer<Y>?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:09:12
问题 This came up mapping from models to mvvmcross viewmodels, where you have some container classes you might use, for example: namespace MvvmCross.Binding { interface INC<T> { T Value { get; set; } } } class model { String name { get; set; } DateTime when { get; set; } othermodel data { get; set; } } class viewmodel { INC<String> Name { get; set; } INC<String> When { get; set; } INC<otherviewmodel> Data { get; set; } } I need to teach AutoMapper to map from A to INC<B> (and back), without

Automapper 6.0.2.0, Mapper.Map() throws StackOverflow when mapping Child Entities

谁说我不能喝 提交于 2019-12-11 14:08:34
问题 Getting straight to the point, I've got the following Models: public abstract class ControlData { public DateTime CreatedDate { get; set; } public int CreatedById { get; set; } [ForeignKey("CreatedById")] public Collaborator CreatedBy { get; set; } public DateTime? UpdatedDate { get; set; } public int? UpdatedById { get; set; } [ForeignKey("UpdatedById")] public Collaborator UpdatedBy { get; set; } } [Table("My_Position_Table")] public class Position : ControlData { [Key] [Column("PositionId"

AutoMapper setting destination object to null

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 13:39:40
问题 I have been following this article: https://medium.com/ps-its-huuti/how-to-get-started-with-automapper-and-asp-net-core-2-ecac60ef523f But when I get to the actual mapping part my destination is null. Can anyone tell me what I'm doing wrong? Startup.cs public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded

What is the correct url for checking out AutoMapper from googlecode?

徘徊边缘 提交于 2019-12-11 12:52:41
问题 I am referring to this project by Jimmy Bogard: http://www.codeplex.com/AutoMapper The code repository site is: http://code.google.com/p/automapperhome/source/checkout The instructed checkout command is: svn checkout http://automapperhome.googlecode.com/svn/trunk/ automapperhome-read-only This does not work. I have tried SlikSVN, Tortoise SVN, QSVN, and possibly others that I've forgotten about. Client: Tortoise SVN Url: svn://automapperhome.googlecode.com/svn/trunk/ automapperhome-read-only

How should AutoMapper access my DAL?

感情迁移 提交于 2019-12-11 12:37:39
问题 I have an InvoiceInputModel with a ProjectId property which is a reference to a Project entity. Ideally, I want AutoMapper to be able to map an entire Invoice entity from an InvoiceInputModel , which looks like this: public class InvoiceInputModel { public Guid Id { get; set; } public DateTime Date { get; set; } public string Reference { get; set; } public Guid ProjectId { get; set; } } Obviously the following is bad: Mapper.CreateMap<InvoiceInputModel, Invoice>() .ForMember(src => src

Nested Lists and Automapper.Map

和自甴很熟 提交于 2019-12-11 12:15:57
问题 So I have 2 objects,AlbumDto and AlbumMediaDto. public class AlbumDto { public int AlbumId { get; set; } public string Title { get; set; } public DateTimeOffset? AlbumDate { get; set; } public AlbumMediasDto Media { get; set; }// list of media } And I have a method from the repo that would return a list of albums (where each has the properties mentioned above which includes a list of media) var albumsForChild = await GetTenantRepository<IAlbumRepository>().GetAlbumsForChild(childId); So I'm

asp.net mvc automapper parsing

北慕城南 提交于 2019-12-11 11:34:21
问题 let's say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; set;} public SelectList Countries {get; set;} } can automapper be used to perform to parse from Person into PersonViewModel and back ? 回答1: Don't use AutoMapper for this - it's not worth it. For example, in the cases where you have a validation failure and you show the form again - AutoMapper is not executed

I want to place Automapper profile in my Business Layer

孤街浪徒 提交于 2019-12-11 11:04:22
问题 I've created a web api core 2.0 application. I've got my main app and the Business Layer. I want to place the automapper profile in the business layer so that all the mappings are made in the business layer. My business layer is just a class library project. Is this possible? or do I need to place all my mapping in a Profile class in the main app? Just a theoretical explanation can help. 回答1: Yes, it's possible but it depends on where the model classes reside. You can give each layer or