Hello I try to implement to make add metod for add new person, and
it's work but...
I have 2 tables Osoba (in eng. Person) and Dział (in eng. Department).
Each Osoba can have 1 Dział. So now my working code is:

private void btnAddPerson_Click(object sender, EventArgs e)
        {

            Dział newDepartment = new Dział
            {
                Nazwa = comboBox1.SelectedValue.ToString()
            };

            Osoba newPerson = new Osoba
            {
                Imie = txtFirstName.Text,
                SumaWydatkow =
Convert.ToInt32(numericSumaWydatkow.Value),
                Dział = newDepartment
                //Dział = comboBox1.SelectedValue.ToString()
            };

            using (ISession dbSession =
SessionProvider.Instance.SessionFactory.OpenSession())
            {
                using (ITransaction transaction =
dbSession.BeginTransaction())
                {
                    dbSession.Save(newDepartment);
                    dbSession.Save(newPerson);

                    transaction.Commit();
                    MessageBox.Show("You have successfully added
person");
                }
            }
        }

It works but if i create a new Dział (Department) like you could see.
But I want use this:

Dział = comboBox1.SelectedValue.ToString()

instead of:

Dział = newDepartment

Because in combobox I have all names of exisiting Departments.
It is possible do do that in NHibernate?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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