Created
April 19, 2013 14:25
-
-
Save luisrudge/5420694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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