I encountered the same problem.
How can I cast Iset to List every time?!

On Wednesday, October 5, 2011 2:49:32 PM UTC+2, Goran wrote:
>
> As additionaI information, if everytime I cast currentInvoice.Items 
> (which is of type ISet<InvoiceItem>) to List<InvoiceItem>, then 
> binding work without any problem. Is there no way I can bind to Iesi 
> Iset<>? 
>
> On Oct 3, 9:58 pm, Goran <[email protected]> wrote: 
> > I am trying to do a simple master detail databinding to Invoice / 
> > Invoice Items, and I am unable to make it work. 
> > 
> > // part in the invoice mapping 
> > HasMany(x => x.Items) 
> >     .KeyColumn("InvoiceId") 
> >     .Inverse() 
> >     .Fetch.Select() 
> >     .AsSet(); 
> > 
> > // part of the InvoiceItems mapping 
> > Id(x => x.Id) 
> > .GeneratedBy.Native(); 
> > ... 
> > 
> > References(x => x.Invoice) 
> >     .Class(typeof(InvoiceInfo)) 
> >     .Not.Nullable() 
> >     .Column("InvoiceId") 
> >     .Fetch.Select(); 
> > 
> > // binding part 
> > invoiceBindingSource.​DataSource = repository.GetInvoices(); 
> > invoiceItemsBindingSource.​DataSource = invoiceBindingSource; 
> > invoiceItemsBindingSource.​DataMember = "Items"; 
> > 
> > gridInvoice.DataSource = invoiceBindingSource; // DataGridView 
> > gridInvoiceItems.DataSource = invoiceItemsBindingSource; // 
> > DataGridView 
> > 
> > When I start application, invoices are present correctly, and items in 
> > first Invoice are present correctly. However, when I try to move to 
> > second invoice item, I get the following exception: 
> > 
> > Exception type: System.Reflection.​TargetInvocationException 
> > Message: Property accessor 'Id' on object 
> > 
> 'NHibernate.Collection.​Generic.PersistentGenericSet`​1[[Model.RacunRobaPodaciInfo,
>  
>
> > model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' threw 
> > the following exception:'Object does not match target type.' 
> > Source: System 
> > Target site: System.Object GetValue(System.Object) 
> > Stack trace:    at 
> > System.ComponentModel.​ReflectPropertyDescriptor.​GetValue(Object 
> > component) 
> >    at 
> > 
> System.Windows.Forms.​DataGridView.​DataGridViewDataConnection.​GetValue(Int32
>  
>
> > boundColumnIndex, Int32 columnIndex, Int32 rowIndex) 
> > 
> > And after this I receive the same exception for the first invoice 
> > also, which was before displayed correctly. I have displayed only one 
> > column for sake of clarity, but if I add more columns to InvoiceItems 
> > DataGridView, I will receive the same fault for each column. Any ideas 
> > why is this happening? 
> > 
> > Thanks, 
> > Goran

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/MJD2W_IsELkJ.
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