dto-mapping

Separating concerns with Linq To SQL and DTO's

北战南征 提交于 2020-01-10 18:21:07
问题 I recently started a new webforms project and decided to separate the business classes from any DBML references. My business layer classes instead access discrete Data layer methods and are returned collections of DTO's. So the data layer might project DTO's like the following: (from c in dataContext.Customers where c.Active == true select new DTO.Customer { CustomerID = c.CustomerID, Name = c.CustomerName, ... }).ToList() Although building the DTO objects adds work, this feels like a better

How to map objects (DTO) on client side?

て烟熏妆下的殇ゞ 提交于 2019-12-11 09:52:00
问题 Typescript ABP + .NET Core I'm using a grid to insert rows (the grid I'm using is a component of the DevExtreme framework). Anyway, similar to other grids, it raises onRowInserting events when the records are inserted, providing the inserted row as a parameter. I need to convert that "anonymous" object (the inserted data) to my client-side DTO in this event. onRowInserting(e) { let mynewrow: ItemDto = e.data; // e.data contains the inserted row } To better understand what I need to achieve,

Separating concerns with Linq To SQL and DTO's

故事扮演 提交于 2019-11-30 12:46:55
I recently started a new webforms project and decided to separate the business classes from any DBML references. My business layer classes instead access discrete Data layer methods and are returned collections of DTO's. So the data layer might project DTO's like the following: (from c in dataContext.Customers where c.Active == true select new DTO.Customer { CustomerID = c.CustomerID, Name = c.CustomerName, ... }).ToList() Although building the DTO objects adds work, this feels like a better approach to a tight binding between Business & Data layers and means I can test the Business layer

AutoMapper issue

此生再无相见时 提交于 2019-11-29 11:37:27
Trying to automap some objects. Source objects has properties with _ before name, destination objects - have not. Is it possible to implement ONE map creation, that automapper would map all _properties to properties for all source types. class MyMapper<TFrom, TTo>{ TTo PerformMap(TFrom fromObject){ Mapper.CreateMap<From, To>(); // ??? TTo result = Mapper.Map<From, To>(fromObject); //result.Id.ShouldBe(value from TFrom._Id); return result; } } class From { public int _Id { get; set; } public string _Name { get; set; } } class To { public int Id { get; set; } public string Name { get; set; } }

AutoMapper issue

荒凉一梦 提交于 2019-11-28 04:37:45
问题 Trying to automap some objects. Source objects has properties with _ before name, destination objects - have not. Is it possible to implement ONE map creation, that automapper would map all _properties to properties for all source types. class MyMapper<TFrom, TTo>{ TTo PerformMap(TFrom fromObject){ Mapper.CreateMap<From, To>(); // ??? TTo result = Mapper.Map<From, To>(fromObject); //result.Id.ShouldBe(value from TFrom._Id); return result; } } class From { public int _Id { get; set; } public