I don't understand... what is the JSON sting ? What is the
ChildRepository class ? Don't understand how nhibernate know how to
load the associated class and the collection properties.

On 6 oct, 23:38, webpaul <[email protected]> wrote:
> From the JSON string, create your classes, let's call them Parent and
> the child class Child.
>
> var repository = new ChildRepository();
>
> foreach item
>   var parent = new Parent { Label = myjsonReader.label, ... };
>   parent.Children = repository.GetForParent(parent.Label);
>
> Or
>
> var repository = new ChildRepository();
> var allChildren = repository.GetAll().ToDictionary(x => x.Label);
>
> foreach item
>   var parent = new Parent { Label = myjsonReader.label, ... };
>   parent.Children = allChildren.Where(x => x.Label ==
> parent.Label).ToList();
>
> On Oct 5, 9:51 am, mathmax <[email protected]> wrote:
>
> > Sry, I don't understand. How to load the collection via a repository
> > that is mapped?
>
> > On 5 oct, 15:16, webpaul <[email protected]> wrote:
>
> > > Create the class from the strings as Oskar suggested, load the
> > > collection via a repository that is mapped.
>
> > > On Oct 3, 2:20 pm, mathmax <[email protected]> wrote:
>
> > > > Because the entities also have collection property that should be
> > > > loaded via NHibernate.
>
> > > > On 3 oct, 18:57, Oskar Berggren <[email protected]> wrote:
>
> > > > > When you parse that string, why don't you create instances of some
> > > > > "real" entity class directly, skipping the DataTable entirely?
>
> > > > > /Oskar
>
> > > > > 2009/10/3 mathmax <[email protected]>:
>
> > > > > > I have to load entities from a single field value containing a 
> > > > > > string
> > > > > > to parse that look like this:
>
> > > > > > {
> > > > > >        label: "France by UPS Standard",
> > > > > >        destination: "FR",
> > > > > >        fees_table: "10000:14.95"
> > > > > > }
> > > > > > {
> > > > > >        label: "France by GLS-Deutschland Standard",
> > > > > >        destination: "FR",
> > > > > >        fees_table: "10000:14.95"
> > > > > > }
> > > > > > ...
>
> > > > > > So I get these data with a DbCommand, parse them and fill a 
> > > > > > dataTable.
> > > > > > Then I currently create a table to the database side from this
> > > > > > dataTable. After that, I use nHibernate to load this entities from
> > > > > > this new table and all the associated classes. The other classes are
> > > > > > binded to normal existing tables.
> > > > > > So I find it painful to recreate a table each time on the database
> > > > > > side, just to be able to load my entities with nhibernate. It would 
> > > > > > be
> > > > > > nice If I could load them directly from the datatable. Is there any
> > > > > > way to do this ?
>
> > > > > > On 3 oct, 17:50, Ben Scheirman <[email protected]> wrote:
> > > > > >> Not really.  Where are you getting this data table?  Are you 
> > > > > >> performing a
> > > > > >> query against a database to get it?
>
> > > > > >> NHibernate is specifically designed to manage persistence with 
> > > > > >> your own
> > > > > >> database, so if you're retreiving this database yourself, or from 
> > > > > >> another
> > > > > >> place (file system, web service) then you should re-think how you 
> > > > > >> plan on
> > > > > >> using NHibernate.
>
> > > > > >> On Sat, Oct 3, 2009 at 8:37 AM, mathmax 
> > > > > >> <[email protected]> wrote:
>
> > > > > >> > Hello,
>
> > > > > >> > I would like to load an entity from a DataTable. Is it possible ?
>
> > > > > >> > Thanks.- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to