you're welcome.
On Wed, Apr 29, 2009 at 2:29 PM, Darius Damalakas < darius.damala...@gmail.com> wrote: > > Great! > thank you mery much. > > It also explains why a call to > ActiveRecordMediator<Company>.FindByPrimaryKey(0) does not fail, even > there is no such Company in the database > > > I even checked NHibernate in action (i've got a June 2008 version). > Chapter "4.4.1 Retrieving objects by identifier" explains everything > in enough detail > > > On 29 Bal, 13:19, Ken Egozi <egoz...@gmail.com> wrote: > > use the "bool throwOnNotFound" overload of FindByPrimaryKey. > > it will use NH's Load method, which does not hit the DB, but rather > creates > > a proxy with ID - just what you need, and you keep the OO semantics. > > > > newBill.RecipientCompany = > > ActiveRecordMediator<Company>.FindByPrimaryKey(record.RecipientCompanyId, > * > > true*); > > > > On Wed, Apr 29, 2009 at 12:13 PM, Darius Damalakas < > > > > > > > > darius.damala...@gmail.com> wrote: > > > > > I need to create some thousand of records. > > > > > For each record I have selected a payerCompanyID and > > > recipientCompanyId fields with HQL query (aggregation, summing, ant > > > stuff). > > > > > Is it possible somehow to insert into database a new Bill record > > > without fetching Company from database? > > > > > Now i have this: > > > newBill.RecipientCompany = > > > ActiveRecordMediator<Company>.FindByPrimaryKey > > > (record.RecipientCompanyId); > > > newBill.PayerCompany = ActiveRecordMediator<Company>.FindByPrimaryKey > > > (record.PayerCompanyId); > > > ActiveRecordMediator.Save(newBill) > > > > > Instead, i would like to have this: > > > newBill.RecipientCompany.Id = record.RecipientCompanyId; > > > newBill.PayerCompany.Id = record.PayerCompanyId; > > > ActiveRecordMediator.Save(newBill) > > > > > Is it somehow possible? It should be, because if i load a bill, then > > > both Company fields are not loaded, but the Id can be accessed. So > > > both companies are unitialized proxies. Maybe something liek this > > > would work: > > > newBill.RecipientCompany.Id = NHUtils.MakeUnitializedProxy<Company> > > > (record.RecipientCompanyId); > > > newBill.PayerCompany.Id = NHUtils.MakeUnitializedProxy<Company> > > > (record.PayerCompanyId); > > > ActiveRecordMediator.Save(newBill) > > > > > Thank you for any ideas > > > > -- > > Ken Egozi. > http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---