/// <summary> /// CommandInfo得到返回结果 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ormDataBase"></param> /// <param name="obj"></param> /// <param name="cmd"></param> /// <param name="query"></param> /// <returns></returns> protected virtual T GetInfosByCommand <T>(OrmDataBaseInfo ormDataBase, OrmObjectInfo obj, SqlCommand cmd, QueryInfo query) { if (string.IsNullOrEmpty(cmd.CommandText)) { return(default(T)); } using (var sqlcon = GetConnnection <SqlConnection>(ormDataBase.GetAllGetOrmDataBase(), query)) { cmd.Connection = sqlcon; return(GetInfosByType <T>(query, obj, cmd)); } }
/// <summary> /// 执行查询存储过程 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ormDataBase"></param> /// <param name="commandText"></param> /// <param name="commandType"></param> /// <param name="parameters"></param> /// <returns></returns> public override T ExecuteQuery <T>(OrmDataBaseInfo ormDataBase, string commandText, CommandType commandType, params object[] parameters) { if (string.IsNullOrEmpty(commandText) || ormDataBase == null) { return(default(T)); } using (var sqlcon = GetConnnection <SqlConnection>(ormDataBase.GetAllGetOrmDataBase(), null)) { var sqlcmd = new SqlCommand(); sqlcmd = FillCommandTypeCommand(sqlcmd, commandText, commandType, parameters); sqlcmd.Connection = sqlcon; return(GetInfosByType <T>(null, null, sqlcmd)); } }