社区
非技术区
帖子详情
国庆到了,祝大家节日快乐,散分~
科技互联人生
2005-09-30 08:26:34
国庆到了,祝大家节日快乐,散分~
顺便调查一下大家都有哪些活动吧!
我先来讲,打算先去书店逛逛,买几本书回去闭关研读,
工作太忙,都没时间读书了哇~
...全文
260
56
打赏
收藏
国庆到了,祝大家节日快乐,散分~
国庆到了,祝大家节日快乐,散分~ 顺便调查一下大家都有哪些活动吧! 我先来讲,打算先去书店逛逛,买几本书回去闭关研读, 工作太忙,都没时间读书了哇~
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
56 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
科技互联人生
2006-05-11
打赏
举报
回复
/// <summary>
/// Delete an object
/// </summary>
/// <param name="obj"></param>
public static void DeleteObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Delete(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
/// <summary>
/// Find by HQL
/// </summary>
/// <param name="obj"></param>
public static System.Collections.IList Find(string HQL)
{
ISession session = CurrentSession();
System.Collections.IList list = null;
try
{
list = session.Find(HQL);
}
catch (Exception ex)
{
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
return list;
}
/// <summary>
/// To get the specify object from DB
/// </summary>
/// <param name="ClassType"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static Object GetObject(Type ClassType, object ID)
{
ISession session = CurrentSession();
object Getobj = null;
try
{
Getobj = session.Get(ClassType, ID);
return Getobj;
}
catch (Exception ex)
{
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
/// <summary>
/// To see whether an object exists
/// </summary>
/// <param name="ClassType"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static bool ObjExist(Type ClassType, object ID)
{
object Getobj = GetObject(ClassType, ID);
if (Getobj == null)
{
return false;
}
else
{
return true;
}
}
#endregion
#region For making hbm2ddl
/// <summary>
/// DDL file path
/// </summary>
private static string DllOutPutPath = @"D:\\HbmDDL.txt";
/// <summary>
/// Configuration file name
/// </summary>
private static string DllMappingFile = "hibernate.cfg.xml";
/// <summary>
/// Make DDL file
/// </summary>
/// <param name="hbmConfigurationfile">The hbm configuration file</param>
public static void MakeDDL(string hbmConfigurationfile)
{
if (!System.IO.File.Exists(hbmConfigurationfile))
{
return;
}
NHibernate.Cfg.Configuration Cfg = null;
try
{
Cfg= new Configuration().Configure(hbmConfigurationfile);
}
catch (Exception e)
{
Logger.Error(e.Message);
throw new HibernateException(e);
}
NHibernate.Tool.hbm2ddl.SchemaExport schemaExport = new NHibernate.Tool.hbm2ddl.SchemaExport(Cfg);
schemaExport.SetOutputFile(DllOutPutPath);
schemaExport.Create(false, false);
//schemaExport.Execute(false, false, false, false);
}
/// <summary>
/// Make DDL file
/// </summary>
public static void MakeDDL()
{
MakeDDL(DllMappingFile);
}
#endregion
}
}
科技互联人生
2006-05-11
打赏
举报
回复
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using Training.Common;
using NHibernate.Cfg;
using NHibernate;
using NHibernate.Engine;
namespace Training.BusinessProvider
{
public static class HibUnit
{
#region For data operation
/// <summary>
/// The singleton Sessionfactory
/// </summary>
private static NHibernate.ISessionFactory SessionFactory = null;
/// <summary>
/// The configuration file name
/// </summary>
private static string ConfigFileName = "hibernate.cfg.xml";
/// <summary>
/// Gets the sessionfactory
/// </summary>
/// <param name="assemblyName">Application assembly name ,configuration will search the objects in the assembly</param>
/// <returns></returns>
private static ISessionFactory GetSessionFactory(string assemblyName)
{
if (SessionFactory != null)
{
return SessionFactory;
}
NHibernate.Cfg.Configuration Cfg = null;
try
{
Cfg = new Configuration().Configure(ConfigFileName);
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
if (assemblyName != null)
{
System.Reflection.Assembly aa = System.Reflection.Assembly.Load(assemblyName);
Cfg.AddAssembly(aa);
}
try
{
SessionFactory = Cfg.BuildSessionFactory();
return SessionFactory;
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
}
/// <summary>
/// Another method of gets sessions
/// </summary>
/// <returns></returns>
private static ISessionFactory GetSessionFactory()
{
return GetSessionFactory(null);
}
/// <summary>
/// Get session
/// </summary>
/// <returns></returns>
public static ISession CurrentSession()
{
ISessionFactory factory = GetSessionFactory();
try
{
ISession Session = factory.OpenSession();
return Session;
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
}
/// <summary>
/// Reload configuration
/// </summary>
public static void ReloadConfig()
{
SessionFactory = null;
}
/// <summary>
/// Use Hibernate to execute SQL statment
/// </summary>
/// <param name="query"></param>
/// <returns></returns> IList
public static System.Collections.IList ExecuteSQL(string query)
{
System.Collections.IList result = new ArrayList();
ISessionFactoryImplementor s = (ISessionFactoryImplementor) GetSessionFactory();
IDbCommand cmd = s.ConnectionProvider.Driver.CreateCommand();
cmd.CommandText = query;
IDbConnection conn = s.OpenConnection();
try
{
cmd.Connection = conn;
IDataReader rs = cmd.ExecuteReader();
while (rs.Read())
{
int fieldCount = rs.FieldCount;
object[] values = new Object[fieldCount];
for (int i = 0; i < fieldCount; i++)
{
values[i] = rs.GetValue(i);
}
result.Add(values);
}
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
finally
{
s.CloseConnection(conn);
}
return result;
}
/// <summary>
/// Saves an object to DB
/// </summary>
/// <param name="obj"></param>
public static void SaveObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Save(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
/// <summary>
/// Update an object to DB
/// </summary>
/// <param name="obj"></param>
public static void UpdateObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Update(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
/// <summary>
/// SaveOrUpdate an object to DB
/// </summary>
/// <param name="obj"></param>
public static void SaveOrUpdateObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.SaveOrUpdate(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
科技互联人生
2006-05-11
打赏
举报
回复
http://download.microsoft.com/download/0/7/e/07e204a1-4d21-471c-acb9-efd7b98831d8/winfxsetup.exe
http://download.microsoft.com/download/a/3/a/a3a0d427-6065-4c9a-a4a3-734e11bfdaa1/winfxsetup.exe
------------------------------------------------------------------
http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/WindowsSDK_Readme_FebCTP.htm
http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/6.0.5308.0.9.WindowsSDK_Vista_idw.DVD.Rel.img
http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/Setup.exe
hoowoo
2005-10-04
打赏
举报
回复
现在学习ASP.NET 2.0
呵呵!!
teachme123
2005-10-03
打赏
举报
回复
学习
richardingding
2005-10-03
打赏
举报
回复
mark一下
终于可以好好的休息一下了
jialw
2005-10-03
打赏
举报
回复
学习
truewill
2005-10-03
打赏
举报
回复
终于可以睡到中午了 ^_^
mywebcom
2005-10-01
打赏
举报
回复
普天同庆!
yufenfeila
2005-10-01
打赏
举报
回复
节日快乐!
到处转转
xilo
2005-10-01
打赏
举报
回复
看书,上网,睡觉。。。
gyf19
2005-10-01
打赏
举报
回复
节日快乐!
Overriding
2005-09-30
打赏
举报
回复
买几本书回去闭关研读
==============
楼主比较幸福,我回家干几天体力活。
commars
2005-09-30
打赏
举报
回复
节日快乐!
wdcszl
2005-09-30
打赏
举报
回复
学习
gyf19
2005-09-30
打赏
举报
回复
祝大家国庆节快乐!!!节日看书,好久没有看书。
Alden
2005-09-30
打赏
举报
回复
I{
showrock
2005-09-30
打赏
举报
回复
节日快乐~明开始休息了~准备去迷笛音乐节休闲一下~
健者天行
2005-09-30
打赏
举报
回复
节日快乐,同乐!
supermarrio
2005-09-30
打赏
举报
回复
我根maomilaile(阿来) 一样,准备要找工作了,原来的单位不行了。大家国庆快乐哈^_^
加载更多回复(36)
青少儿编程-Python游戏一刻钟迎
国庆
套餐价特惠
针对青少儿编程-Python游戏一刻钟的套餐价-迎五一特惠 内部包括: 青少儿编程-Python游戏一刻钟(上)(中)(下) 价格更优惠。 1、本课程属于青少儿创意编程,以飞机大战的游戏为蓝本来教会孩子编写游戏 2、每章在...
祝
大家
国庆
、中秋双节快乐!!!
祝
:万事大吉,心想事成!
国庆
中秋双双庆,在这个特别、美好、难忘的日子里,让我们所有的华夏子孙共
祝
愿祖国盛!家团圆!人幸福!酒越久越醇,朋友相交越久越真;水越流越清,世间沧桑越流越淡。
国庆
重阳两佳节,...
html程序
国庆
节
祝
福,2019
国庆
节
祝
福语送给朋友微信
用十足的真诚
祝
福你,愿你魅力十足,生活十全十美,过一个快乐的
国庆
节。3. 十月天高云淡,秋日阳光灿烂,喜庆枫叶红遍,千山层林尽染。大街小巷快乐弥漫,东南西北烟火璀璨,
国庆
佳节绽放笑颜,衷...
2019年十一
国庆
祖国,你走过了不平凡的70年,像一个婴儿长成了壮年,今日您正充满活力,散发着蓬勃的朝气,您有过磨难,也有过欢笑。历经了崎岖坎坷,明天将更加美好。 70年来,你发生了翻天覆地的变化,...
国庆
——献给亲爱的祖...
中秋节
祝
福短信
祝
福中秋佳节快乐,月圆人圆事事团圆。人顺心顺事事都顺。
祝
全家幸福、和气满堂、合家欢乐!月圆家圆人圆事圆圆圆团团,国和家和人和事和和和美美。
祝
全家幸福、和气满堂、合家欢乐!关掉你的手机,慢慢的闭上眼睛,...
非技术区
7,765
社区成员
63,203
社区内容
发帖
与我相关
我的任务
非技术区
.NET技术 非技术区
复制链接
扫一扫
分享
社区描述
.NET技术 非技术区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章