Skip to content

Instantly share code, notes, and snippets.

@luisrudge
Created April 19, 2013 14:25
Show Gist options
  • Save luisrudge/5420694 to your computer and use it in GitHub Desktop.
Save luisrudge/5420694 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using FamilyClub.Data.Mappers;
using FamilyClub.Model;
using TecUnica.Core.Data.NPoco;
namespace FamilyClub
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
var container = Bootstrapper.Initialize();
WebApiConfig.Register(GlobalConfiguration.Configuration);
RouteConfig.RegisterRoutes(RouteTable.Routes);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, container);
var mappers = new Dictionary<Type, INPocoMapper>
{
{ typeof (Brand), new BrandMapper() },
{ typeof (Campaign), new CampaignMapper() },
{ typeof (Catalogue), new CatalogueMapper() },
{ typeof (Reward), new RewardMapper() },
{ typeof (Participant), new ParticipantMapper() },
{ typeof (ParticipantInterest), new ParticipantInterestMapper() }
};
NPoco.Database.Mapper = new NPocoEntityMapper(mappers);
}
}
}
using System.Collections.Generic;
using NPoco;
using TecUnica.Core.Data.NPoco;
namespace FamilyClub.Data.Mappers
{
public class CampaignMapper : INPocoMapper
{
public TableInfo GetTableInfo()
{
return new TableInfo
{
AutoIncrement = true,
PrimaryKey = "idCampaign",
TableName = "tbCampaign"
};
}
public IEnumerable<EntityMapping> GetMapping()
{
return new[]
{
new EntityMapping { ClassPropertyName = "Id", DatabaseColumnName = "idCampaign" },
new EntityMapping { ClassPropertyName = "Name", DatabaseColumnName = "camName"}
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment