English 中文(简体)
我如何获得自治应用者来绘制地图?
原标题:How do I get AutoMapper to map this?
  • 时间:2010-03-15 00:31:50
  •  标签:
  • automapper

我有这一类:

public class Account
{
    public int AccountID { get; set; }
    public Enterprise Enterprise { get; set; }
    public List<User> UserList { get; set; }
}

当我使用自动交换机绘制账户类别地图时,我也希望它绘制企业类别图,并绘制返回物体的用户名单。 我怎么能让自治者这样做?

感谢!

最佳回答

如果能为企业和用户类别提供配置,则自动交换机在箱子之外这样做。

结构如此:

Mapper.CreateMap<Account, AccountDto>();
Mapper.CreateMap<Enterprise, EnterpriseDto>();
Mapper.CreateMap<User, UserDto>();

This shows how to how collections get mapped: http://automapper.codeplex.com/wikipage?title=Lists%20and%20Arrays&referringTitle=Home

问题回答

你们需要为你们所希望绘制的几端绘制地图。

Mapper.CreateMap<Account, AccountDto>();
Mapper.CreateMap<Enterprise, EnterpriseDto>();
Mapper.CreateMap<User, UserDto>();

命令并不重要。





相关问题
AutoMapper With Generic Type Inheritance

I m trying to map CustomerDTO with my domain entity ICustomer with AutoMapper. Everything works fine for first inheritance level but not for the others. I m using Interfaces for my domain model since ...

C# automapper nested collections

I have a simple model like this one: public class Order{ public int Id { get; set; } ... ... public IList<OrderLine> OrderLines { get; set; } } public class OrderLine{ public int ...

Automapper, generics, dto funtimes

Here s the deal: I have a report designer where users can create reports based on some predefined datasets. They can select a set of columns to include in the report and then, when the report is ran, ...

Problem with AutoMapper in IIS7 when using signed assemblies

I am trying to use AutoMapper with web application running on IIS 7. The intended use it so map domain types defined in an external dll to view models defined in the IIS application. This works fine ...

asp.net mvc automapper parsing

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; ...

热门标签