Click here to Skip to main content
15,898,804 members
Home / Discussions / C#
   

C#

 
AnswerRe: Event and EventArg data propagation though nested UserControls Pin
DaveyM6917-Apr-09 11:56
professionalDaveyM6917-Apr-09 11:56 
QuestionDatabase in C# Pin
linto_1117-Apr-09 9:51
linto_1117-Apr-09 9:51 
AnswerRe: Database in C# Pin
Eddy Vluggen18-Apr-09 0:01
professionalEddy Vluggen18-Apr-09 0:01 
Questionbicturebox Pin
abu anas alazuneh17-Apr-09 9:40
abu anas alazuneh17-Apr-09 9:40 
AnswerRe: bicturebox Pin
Luc Pattyn17-Apr-09 9:43
sitebuilderLuc Pattyn17-Apr-09 9:43 
GeneralRe: bicturebox Pin
ammar_shaker17-Apr-09 23:00
ammar_shaker17-Apr-09 23:00 
GeneralRe: bicturebox Pin
Eddy Vluggen18-Apr-09 0:04
professionalEddy Vluggen18-Apr-09 0:04 
QuestionInsert into child table in nhibernate 2.1.0 Pin
highjo17-Apr-09 9:22
highjo17-Apr-09 9:22 
hello good gurus.I've hesitated a lot before posting here coz i've been doing research(some of the articles here are too advanced for me Smile | :) ) but righ now i don't have the choice.it' seems that forum.hibernate.org is pointing to jboss for some reasons i don't know so please...
i'm new to nhibernate and i wanted to do a small application with 3 tables(i use 2 for now).table currency and table country here are the mapping files


<?xml version="1.0" encoding="utf-8" ?>
//country table mapping
<class name="dataprovider.Country,dataprovider" table="country">

<id name="CountryId" column="country_id" unsaved-value="0">
<generator class="native"/>
</id>
<!--<bag name="BatchList" inverse="true" lazy="true" >
<key column="country_id" />
<one-to-many class="Batch" />
</bag>
<bag name="PrinterList" inverse="true" lazy="true" >
<key column="country_id" />
<one-to-many class="Printer" />
</bag>-->
<many-to-one name="CurrencyId" column="currency_id" class="Currency" cascade="save-update"/>
<!--<property column="currency_id" name="Currency_Id"/>-->
<property column="name" name="Name"/>
<property column="region" name="Region" />
<property column="comments" name="Comments"/>

//currency table mapping
<id name="CurrencyId" column="currency_id" >
<generator class="native"/>
</id>
<bag name="CountryList" inverse="true" lazy="true" >
<key column="currency_id" />
<one-to-many class="Country" />
</bag>
<!--<bag name="DenominationList" inverse="true" lazy="true" >
<key column="currency_id" />
<one-to-many class="Denomination" />
</bag>-->
<property column="name" name="Name"/>
<property column="authorizer" name="Authorizer" />
<property column="date_created" name="DateCreated" type="DateTime" not-null="true" />
<property column="comments" name="Comments" />

the many to one relationship that country hold is an attribute of the type Currency in the country persistence class.Now while my test can_add_currency and can_add_country succeeded(i export the schema) i have null value in the table country on the field currency_id. here is the test code

<code>[Test]
public void can_add_new_country()
{
CountryManager cm = new CountryManager();

Country country = new Country();
//country.CurrencyId = CurrencyManager.GetCurrencyById(1);
country.CurrencyId = new CurrencyManager().GetCurrencyById(1);
country.Name = "POUND";
country.Region = "ENGLAND";
country.Comments = "the comment";


cm.Add(country);

using(ISession session = _sessionFactory.OpenSession())
{
Country fromdb = session.Get<Country>(country.CountryId);
Assert.IsNotNull(fromdb);
Assert.AreNotSame(fromdb, country);

}
}

public Currency GetCurrencyById(int currency_id)
{//GetCurrencyById from CurrencyManger class
try
{
using(ISession session = NHibernateHelper.OpenSession())
{
return session.Get<Currency>(currency_id);

}
} catch (Exception ex)
{

return null;
}
}

</code>

so the question is HOW TO INSERT INTO TABLE COUNTRY WITH THE CURRENCY_ID OF AN EXISTING CURRENCY_ID FROM THE TABLE CURRENCY? for example there is a currency with the currency_id=1, i want to insert to the country table and have currency_id=1 in the foreign key that is in country table.How you guys do it?i'm seriously stacked and 2 days small project is taking me one week now.Please have pity Smile | :) thanks for reading

eager to learn
QuestionRegistry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 8:25
JimDel17-Apr-09 8:25 
AnswerRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 9:13
sitebuilderLuc Pattyn17-Apr-09 9:13 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 9:32
JimDel17-Apr-09 9:32 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 9:41
sitebuilderLuc Pattyn17-Apr-09 9:41 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 10:41
JimDel17-Apr-09 10:41 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 10:48
sitebuilderLuc Pattyn17-Apr-09 10:48 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 11:00
JimDel17-Apr-09 11:00 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 11:02
sitebuilderLuc Pattyn17-Apr-09 11:02 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 11:41
JimDel17-Apr-09 11:41 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 11:49
sitebuilderLuc Pattyn17-Apr-09 11:49 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 11:56
JimDel17-Apr-09 11:56 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
harold aptroot17-Apr-09 12:28
harold aptroot17-Apr-09 12:28 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 14:05
JimDel17-Apr-09 14:05 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 14:15
sitebuilderLuc Pattyn17-Apr-09 14:15 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
JimDel17-Apr-09 14:19
JimDel17-Apr-09 14:19 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET Pin
Luc Pattyn17-Apr-09 14:24
sitebuilderLuc Pattyn17-Apr-09 14:24 
GeneralRe: Registry Entry made with advapi32.dll instead of .NET [modified] Pin
JimDel17-Apr-09 14:44
JimDel17-Apr-09 14:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.