I'm looking at converting some old code from Entity Framework to PetaPoco, just need some advice/direction on how to best achieve this.
Currently a single entity is returned with data from two custom tables - I need to replicate that using PetaPoco.
eg
Table 1 contains a group id (PK), name, alias and summary text. Table 2 contains a group id and user id (relating users to groups).
How can my POCO return a model representing all the groups from table 1, with an enumerable object of Umbraco Users, derived from the user id Table 2, where the group id provides the foreign key?
I'm fine with creating the tables dynamically, and storing or querying either table, just not sure how to use a single model to return data from two tables...
I'm fetching the db via ApplicationContext.Current.DatabaseContext.Database, no dramas there.
Think for now I'll just wear the extra db call, and build my own response model. Overhead won't really matter as it's a back office extension rather than a front-end action
Best practice with PetaPoco
I'm looking at converting some old code from Entity Framework to PetaPoco, just need some advice/direction on how to best achieve this.
Currently a single entity is returned with data from two custom tables - I need to replicate that using PetaPoco.
eg
Table 1 contains a group id (PK), name, alias and summary text. Table 2 contains a group id and user id (relating users to groups).
How can my POCO return a model representing all the groups from table 1, with an enumerable object of Umbraco Users, derived from the user id Table 2, where the group id provides the foreign key?
I'm fine with creating the tables dynamically, and storing or querying either table, just not sure how to use a single model to return data from two tables...
Hi Nathan,
First of all I would recommend use one connection to the db per request, we made it with this static method:
Maybe it's not related to your question but it will from connection errors with Peta POCO.
Thanks,
Alex
Thanks Alex
I'm fetching the db via ApplicationContext.Current.DatabaseContext.Database, no dramas there.
Think for now I'll just wear the extra db call, and build my own response model. Overhead won't really matter as it's a back office extension rather than a front-end action
is working on a reply...