A
A
Andrei2014-03-07 11:34:36
NHibernate
Andrei, 2014-03-07 11:34:36

Datagridview - how to load values ​​into DataGridViewComboBoxColumn from DB via Nhibernate?

Greetings.
Do not tell me how to load values ​​from the database into the Datagridview, into the DataGridViewComboBoxColumn via Nhibernate?
Initial conditions. There are two tables Recipes and Products.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  
  <class name="Dietolog.Domain.Products, Dietolog" table="Products" lazy="true">
    <id name="Id" column="Id">
      <generator class="native">
        <param name="sequence">PRODUCTS_ID_GEN</param>
      </generator>
    </id>
    <property name="Name" column="Name" type="String"/>
    <property name="Cost" column="Cost" type="Double"/>
    <property name="IsPerishable" column="Is_Perishable" type="Boolean"/>
  </class>

</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

  <class name="Dietolog.Domain.Recipes , Dietolog" table="Recipes " lazy="true">
    <id name="Id" column="Id">
      <generator class="native">
        <param name="sequence">RECIPES_ID_GEN</param>
      </generator>
    </id>
    <many-to-one name="Product" column="Product_ID"  not-null="true" class="Dietolog.Domain.Products, Dietolog"/>
    <property name="Weight" column="Weight" type="Double"/>
  </class>

</hibernate-mapping>

How can I implement in the Recipes Datagridview, Product column, a drop-down list whose data is loaded from the database, the Products table (Product.Name should be displayed, and Product.ID should be used values)?
How to work with the database through nhibernate is clear, it is not clear how to link two tables into one Datagridview through a drop-down list.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rifat, 2014-03-07
@ngelik

If WPF application, then through DataContext it is possible to specify the list of elements for Combobox.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question