views:

16

answers:

0

Hello, I'm learning NHibernate with Fluenthibernate. I'm using it with C#, Winforms and BindingSource, and I get a Argumentexception by loading a Customer without orders. What can I do or what is wrong?

Mapping:

public class CustomerMap : ClassMap<Customer>
{
    public CustomerMap()
    {
        Id(x => x.Id);
        HasMany(x => x.Orders)
            .Cascade.All();
    }
}



public class OrderMap : ClassMap<Order>
{
    public OrderMap()
    {
        Id(x => x.Id);
        References(x => x.Customer);
    }
}

WinForms Code:

    private void customerBindingSource_CurrentChanged(object sender, EventArgs e)
    {
        if (customerBindingSource.Current is Customer)
            ordersBindingSource.DataSource =
                (customerBindingSource.Current as Customer).Orders;
        else
            ordersBindingSource.DataSource = null;
    }