Hello my friends
I am a beginner in nhibernat.and I should develop an nhibernate
project.
In first step I want read a table from database and show its rows in a
gridview.
The table name is PGroup . the below method has problem and when run
this line
(IQuery iquery = session.CreateQuery(query);) line throws an
exception(Object reference not set to an instance of an object) .
The method is:
---------------------------------------------------------------------------
public static List LoadGroup(string query)
{
try {
session = OpenSession();
IQuery iquery = session.CreateQuery(query);
IList result = iquery.List();
List result_list = result.ToList();
session.Close();
return result_list;
}
catch (Exception ex)
{
return new List();
}
}
------------------------------------------------------------------------------
This method has called from below method:
public static List LoadAllGroups()
{
string query = "from PGroup as p order by p.groupID asc";
List result = Common.LoadGroup(query);
return result;
}
I don’t know what should do!i check classes, mapping files,hbm.xml
files
and set them as embeded resurces.but it doesn’t work.
Please help me.Frown
other information may you need:
PGroup.hbm.xml file is :
"1.0" encoding="utf-8"?>
"TMUShopVakili.Model" assembly="TMUShopVakili" xmlns="urn:nhibernate-
mapping-2.2">
"Pgroup" lazy="true" table="`PGroup`" schema="`dbo`">
"GroupId" access="property" column="`groupID`">
"assigned" />
"GroupDesc" column="`groupDesc`" length="100" />
"GroupName" column="`groupName`" length="50" />
"Products" fetch="select" cascade="save-update">
"`pGroupID`" />
"Product" />
hibernate.cfg.xml file is:
"1.0" encoding="utf-16"?>
"urn:nhibernate-configuration-2.2">
"connection.provider">NHibernate.Connection.DriverConnectionProvider
"dialect">NHibernate.Dialect.MsSql2005Dialect
"connection.driver_class">NHibernate.Driver.SqlClientDriver
"connection.connection_string">Server=PPC;Database=C:\DOCUMENTS
AND
SETTINGS\SAEED\MY DOCUMENTS\VISUAL STUDIO 2008\PROJECTS\TMUSHOPVAKILI
\WEBSITE\APP_DATA\TMUSHOPDB.MDF;Trusted_Connection=True
"proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle
"cache.use_minimal_puts">false
"use_outer_join">false
--
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.