using Cksoft.Data; using Cksoft.Data.Repository; using Cksoft.Unity; using System; using System.Collections.Generic; using System.Data; namespace DllUnityBll { public class UnityBll { /// /// 根据条件查询返回实体集合 /// /// /// /// /// 实体变量 /// /// public IEnumerable SelectForEntity(string dbcode, string condition, object entity, ref string erroinfo) where T : class,new() { IDatabase db = null; try { db = DbFactory.Base(dbcode); string sqlstr = EntityHelper.GetSelectSql(entity,condition, ref erroinfo); IEnumerable redt = db.FindList(sqlstr); return redt; } catch (Exception ex) { erroinfo = ex.Message.ToString(); return null; } finally { if (db != null) db.Close(); } } /// /// 老的查询实体方法 /// /// /// /// /// /// /// public IEnumerable SelectForEntity(string dbcode, string sqlstr, string tablename, ref string erroinfo) where T : class { IDatabase db = null; try { db = DbFactory.Base(dbcode); IEnumerable redt = db.FindList(sqlstr); return redt; } catch (Exception ex) { erroinfo = ex.Message.ToString(); return null; } finally { if (db != null) db.Close(); } } public DataSet Select(string sqlstr, string tablename, ref string erroinfo) { IDatabase db = null; try { string dbcode = "sqlconn"; db = DbFactory.Base(dbcode); DataTable redt = db.FindTableFor(sqlstr, tablename); DataSet tempds = new DataSet(); tempds.Merge(redt); return tempds; } catch (Exception ex) { erroinfo = ex.Message.ToString(); return null; } finally { if (db != null) db.Close(); } } public DataSet Select(string dbcode, string sqlstr, string tablename, ref string erroinfo) { IDatabase db = null; try { db = DbFactory.Base(dbcode); DataTable redt = db.FindTableFor(sqlstr, tablename); DataSet tempds = new DataSet(); tempds.Merge(redt); return tempds; } catch (Exception ex) { erroinfo = ex.Message.ToString(); return null; } finally { if (db != null) db.Close(); } } } }