0

EmployeeDC is having following properties - EmployeeID, EmployeeName, EmployeeLocation. From Database List is returning. How to map this to List using Automapper or any other mechanism in MVC3?


Symfony - Auto redirect

I'd like to create some service that would be responsible for auto-redirecting some routes to secure version of the URL. For example:

http://domain.com/checkout -> https://secure.domain.com/checkout
http://domain.com/about // route not marked as secure, no redirection

I know I can partially achieve that with schema:

secure:
    path:     /secure
    defaults: { _controller: AcmeDemoBundle:Main:secure }
    schemes:  [https]

However I also need to change hosts. Should I hook up to some kernel events or something?

4

2 回答 2

1

这是一个示例 AutoMapper 配置:

请参阅自定义类型转换器

public class EmployeeDC
{
    public int EmployeeID { get; set; }
    public string EmployeeName { get; set; }
    public string EmployeeLocation { get; set; }
}

public class EmployeeConverter : ITypeConverter<object, EmployeeDC>
{
    public EmployeeDC Convert(ResolutionContext context)
    {
        var model = context.SourceValue;

        var employeeId = ???;
        var employeeName = ???;
        var employeeLocation = ???;

        return new EmployeeDC
                   {
                       EmployeeId = employeeId,
                       EmployeeName = employeeName,
                       EmployeeLocation = employeeLocation
                   };
    }
}

Mapper.CreateMap<object, EmployeeDC>()
      .ConvertUsing<EmployeeConverter>();
于 2013-09-06T12:25:49.437 回答
0

I have used both automapper an value injector. i found Value injector is better than auto mapper.

below is the project home page

http://valueinjecter.codeplex.com/

Detail example about to map see the below link. http://sampathloku.blogspot.co.uk/2012/11/how-to-use-valueinjecter-with-aspnet.html

于 2013-09-06T12:27:33.563 回答