Joined: Fri Mar 20, 2009 4:19 am Posts: 11
|
Hi,
I am using Hibernet with ASP.NET. I need to delete a record which is having composite key. Below is the code.
NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
config.AddAssembly(typeof(Project.Main.SC).Assembly);
factory = config.BuildSessionFactory();
session = factory.OpenSession();
String key = " S.Agent_Cd = '" + this.cmbTransAgent.DisplayValue + "'";
key = key + " and S.Crrncy_Cd = '" + this.cmbCcy.DisplayValue + "'";
key = key + " and S.Acct_Cd = '" + this.cmbAcctCode.DisplayValue + "'";
IQuery query = session.CreateQuery("from SettleCycle S where " + key);
//IList<CSTS.Main.SettleCycle> scycle = query.List<CSTS.Main.SC>();
SC scycle = session.get<SC>(cmbAcctCode.DisplayValue);
if (scycle == null)
{
ShowMessageBox("This account information does no exisits!");
}
else
{
try
{
session.Transaction.Begin();
session.Delete(scycle);
session.Transaction.Commit();
ShowMessageBox("Account Deleted");
ClearData();
|
|