I am using PetaPoco/NPoco in my project. The database schema I am working with was not thought our very well and therefore I can't directly bind the POCO to my wpf mvvm view (which is what I used to be able to do when I was also creating the database schema). I am considering two possible solutions to this problem:
Does a proven pattern exist for this problem?
You can manipulate the PetaPoco maps as you wish using ExplicitColumns
to map to a different named column. You can also use ResultColumn
for properties that you wish to grab from the DB for not update/insert. Finally, you can also use unmapped properties for extra work not related to the DB.
namespace Site.Models {
[TableName("Hotel")]
[PrimaryKey("HotelID")]
[ExplicitColumns]
public class Hotel {
[PetaPoco.Column("HotelID")]
public int HotelID { get; set; }
[PetaPoco.Column("HotelClaseID")]
public int? HotelClaseID { get; set; }
[ResultColumn]
public string HotelClase { get; set; }
[Required]
[PetaPoco.Column("Nombre")]
public String Nombre { get; set; }
....