Tried Distinct - still get 10 address records. On Tuesday, October 30, 2012 11:44:01 AM UTC-5, fel0nious wrote:
> I suspect you need a .Distinct() > > ------ > Joe Brockhaus > joe.br...@gmail.com <javascript:> > ------------ > > > On Tue, Oct 30, 2012 at 12:13 PM, rema <rema...@yahoo.com <javascript:>>wrote: > >> That worked. Thanks. >> >> However, as my next requirement the class definition has changed to: >> >> public class Customer >> { >> public long CustomerId {get; set;} >> public CustomerType CustomerType {get; set;} >> public List<CustomerOrder> CustomerOrders {get; set;} >> public List<CustomerAddress> CustomerAddresses {get; set;} >> } >> >> And the issue that I have now run into is that there are 10 customer >> orders and although there is only one customer address, I get 10 records >> there. >> >> >> On Tuesday, October 30, 2012 10:43:05 AM UTC-5, Guido wrote: >> >>> Are you looking for this? >>> >>> var query = >>> session.Query<Customer().**Where(cus => cus.CustomerId == customerId) >>> .Fetch(c => c.CustomerType) >>> .FetchMany(c => c.CustomerOrders) >>> .ThenFetch(co => co.Item) >>> .ToList() >>> ; >>> >>> >>> I had no time for setting up your classes, give it a try >>> >>> On Tue, Oct 30, 2012 at 4:25 PM, rema <rema...@yahoo.com> wrote: >>> >>>> Sorry about that. You are correct. >>>> >>>> The corrected class definition is: >>>> >>>> public class Customer >>>> { >>>> public long CustomerId {get; set;} >>>> public CustomerType CustomerType {get; set;} >>>> public List<CustomerOrder> CustomerOrders {get; set;} >>>> } >>>> >>>> On Tuesday, October 30, 2012 10:17:42 AM UTC-5, Guido wrote: >>>> >>>>> Well maybe you should correct the class definition you posted then. I >>>>> see no list in your class. >>>>> >>>>> >>>>> On Tue, Oct 30, 2012 at 3:54 PM, rema <rema...@yahoo.com> wrote: >>>>> >>>>>> .ThenFetch(co => co.Item) <=== At this time co is a list of customer >>>>>> orders so I have to do a select >>>>>> >>>>>> >>>>>> >>>>>> On Tuesday, October 30, 2012 9:07:16 AM UTC-5, Guido wrote: >>>>>> >>>>>>> Why not >>>>>>> >>>>>>> .ThenFetch(co => co.Item)) >>>>>>> >>>>>>> ? >>>>>>> >>>>>>> >>>>>>> On Mon, Oct 29, 2012 at 3:44 PM, rema <rema...@yahoo.com> wrote: >>>>>>> >>>>>>>> I have the following object structure: >>>>>>>> >>>>>>>> public class CustomerType >>>>>>>> { >>>>>>>> public int CustomerTypeId {get; set;} >>>>>>>> public string TypeName {get; set;} >>>>>>>> } >>>>>>>> >>>>>>>> public class Customer >>>>>>>> { >>>>>>>> public long CustomerId {get; set;} >>>>>>>> public CustomerType CustomerType {get; set;} >>>>>>>> public CustomerOrder CustomerOrders {get; set;} >>>>>>>> } >>>>>>>> >>>>>>>> public class CustomerOrder >>>>>>>> { >>>>>>>> public long CustomerOrderId {get; set;} >>>>>>>> public Item Item {get; set;} >>>>>>>> } >>>>>>>> >>>>>>>> public class Item >>>>>>>> { >>>>>>>> public int ItemId {get; set;} >>>>>>>> public string ItemName {get; set;} >>>>>>>> } >>>>>>>> >>>>>>>> My Query looks like: >>>>>>>> >>>>>>>> var query = >>>>>>>> session.Query<Customer().**Where****(cus => >>>>>>>> cus.CustomerId == customerId) >>>>>>>> .Fetch(c => c.CustomerType) >>>>>>>> .Fetch(c => c.CustomerOrders) >>>>>>>> .ThenFetch(co => co.Select(it => it.Item)).ToList(); >>>>>>>> >>>>>>>> But I get the following error: >>>>>>>> >>>>>>>> "A fetch request must be a simple member access expression; >>>>>>>> '[100002]' is a SubQueryExpression instead.\r\nParameter name: >>>>>>>> relatedObjectSelector" >>>>>>>> >>>>>>>> If I remove the last .ThenFetch - then it works just fine. >>>>>>>> >>>>>>>> I do need to load the Item object >>>>>>>> >>>>>>>> Any ideas? >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Fluent NHibernate" group. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/**ms****g/fluent-nhibernate/-/** >>>>>>>> iVb2xQHY****lGcJ<https://groups.google.com/d/msg/fluent-nhibernate/-/iVb2xQHYlGcJ> >>>>>>>> . >>>>>>>> To post to this group, send email to fluent-n...@** >>>>>>>> googlegroups.com. >>>>>>>> To unsubscribe from this group, send email to fluent-nhibern...@** >>>>>>>> googlegroups****.com. >>>>>>>> >>>>>>>> For more options, visit this group at http://groups.google.com/** >>>>>>>> group****/fluent-nhibernate?hl=en<http://groups.google.com/group/fluent-nhibernate?hl=en> >>>>>>>> . >>>>>>>> >>>>>>> >>>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Fluent NHibernate" group. >>>>>> To view this discussion on the web visit https://groups.google.com/d/ >>>>>> **ms**g/fluent-nhibernate/-/8l-**F2SL4**JDUJ<https://groups.google.com/d/msg/fluent-nhibernate/-/8l-F2SL4JDUJ> >>>>>> . >>>>>> >>>>>> To post to this group, send email to fluent-n...@**googlegroups.com. >>>>>> To unsubscribe from this group, send email to fluent-nhibern...@** >>>>>> googlegroups**.com. >>>>>> For more options, visit this group at http://groups.google.com/** >>>>>> group**/fluent-nhibernate?hl=en<http://groups.google.com/group/fluent-nhibernate?hl=en> >>>>>> . >>>>>> >>>>> >>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Fluent NHibernate" group. >>>> To view this discussion on the web visit https://groups.google.com/d/** >>>> msg/fluent-nhibernate/-/**VZEjcrCaJJMJ<https://groups.google.com/d/msg/fluent-nhibernate/-/VZEjcrCaJJMJ> >>>> . >>>> >>>> To post to this group, send email to fluent-n...@**googlegroups.com. >>>> To unsubscribe from this group, send email to fluent-nhibern...@** >>>> googlegroups.com. >>>> For more options, visit this group at http://groups.google.com/** >>>> group/fluent-nhibernate?hl=en<http://groups.google.com/group/fluent-nhibernate?hl=en> >>>> . >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/fluent-nhibernate/-/QMeLpjjRIL8J. >> >> To post to this group, send email to >> fluent-n...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> fluent-nhibern...@googlegroups.com <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To view this discussion on the web visit https://groups.google.com/d/msg/fluent-nhibernate/-/7iJiCISKzFkJ. To post to this group, send email to fluent-nhibernate@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.