1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EmitMapper;
//using EmitMapper.MappingConfiguration;
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
User u = new User()
{
id = 10,
name = "张三",
g = new Gb { id = 10, GbNAME = "中国" },
};
//这里使用了EmitMapper
var mapper = ObjectMapperManager.DefaultInstance.GetMapper<User,UserView>();
UserView uview = mapper.Map(u);
return View();
}
}
public class User
{
public int id { get; set; }
public string name { get; set; }
public Gb g { get; set; }
}
public class UserView
{
public int id { get; set; }
public string name { get; set; }
public GbView g { get; set; }
}
public class Gb
{
public int id { get; set; }
public string GbNAME { get; set; }
}
public class GbView
{
public int id { get; set; }
public string GbNAME { get; set; }
}
}