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?


You should use -nestedLoad param like this:

a = load 'input' using com.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad') AS (json:map[]).

And then you use the following code:

b = FOREACH a GENERATE (json#'AD') as AD:bag{t:Tuple(m:map[])};

Then your json array become a bag datatype. You can flatten it to get tuple.

c = FOREACH b GENERATE FLATTEN(AD);
d = FOREACH c GENERATE AD::m#ID AS ID, AD::m#C1 AS C1, AD::m#C2 AS C2, AD::m#ST AS ST, AD::m#PO AS PO

At this time, you will get the tuple data type which the schema is (ID:bytearray, C)

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 に答える