/// <summary> /// 获取类的MAPPING名称 /// </summary> /// <param name="type"></param> /// <returns></returns> public static DMSDbType GetStoredProcedureDbType(this Type type) { StoredProcedureMappingAttribute attribute = ReflectionUtils.GetAttribute <StoredProcedureMappingAttribute>(type); if (attribute == null) { return(DMSDbType.MsSql); } return(attribute.DMSDbType); }
internal static StoredProcedureMappingAttribute GetStoredProcedureMappingAttribute(Type type) { StoredProcedureMappingAttribute attribute = ReflectionUtils.GetAttribute <StoredProcedureMappingAttribute>(type, true, new StoredProcedureMappingAttribute() { ConfigName = ConstExpression.TableConfigDefaultValue, Name = type.Name, DMSDbType = DMSDbType.MsSql, }); return(attribute); }
/// <summary> /// 执行查询的存储过程,不分页 /// </summary> /// <typeparam name="T">类型参数必须是引用类型;这一点也适用于任何类、接口、委托或数组类型。</typeparam> /// <param name="iEntity">参数实体</param> /// <param name="errMsg">错误信息</param> /// <returns></returns> private IEnumerable <T> GetListing <T>(ISPEntity iEntity, ref string errMsg) where T : class { StoredProcedureMappingAttribute attribute = DMSExpression.GetStoredProcedureMappingAttribute(iEntity.GetType()); DMSDbProvider provider = DMSExpression.GetDbProvider(attribute.DMSDbType, attribute.ConfigName); using (var conn = provider.GetOpenConnection()) { DynamicParameters parameters = GetParameters(iEntity); return(DMSDbAccess.Query <T>(conn, attribute.Name, attribute.Name, parameters, 0, null, true, 30, System.Data.CommandType.StoredProcedure)); } }
/// <summary> /// 获取实体的MAPPING名称 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static string GetStoredProcedureName(this ISPEntity entity) { if (entity == null) { return(null); } StoredProcedureMappingAttribute attribute = ReflectionUtils.GetAttribute <StoredProcedureMappingAttribute>(entity.GetType()); if (attribute == null) { return(entity.GetType().Name); } return(attribute.Name); }
/// <summary> /// 获取实体的MAPPING名称 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static string GetStoredProcedureConfigName(this ISPEntity entity) { StoredProcedureMappingAttribute attribute = ReflectionUtils.GetAttribute <StoredProcedureMappingAttribute>(entity.GetType()); if (attribute == null || string.IsNullOrEmpty(attribute.ConfigName)) { return(ConstExpression.TableConfigDefaultValue); } if (string.IsNullOrEmpty(attribute.ConfigName)) { return(ConstExpression.TableConfigDefaultValue); } return(attribute.ConfigName); }
/// <summary> /// 执行更新,删除,插入的存储过程 /// </summary> /// <param name="iEntity">存储过程实体类</param> /// <param name="errMsg">错误信息</param> /// <returns></returns> public bool ExecuteNoQuery(ISPEntity iEntity, ref string errMsg) { StoredProcedureMappingAttribute attribute = DMSExpression.GetStoredProcedureMappingAttribute(iEntity.GetType()); DMSDbProvider provider = DMSExpression.GetDbProvider(attribute.DMSDbType, attribute.ConfigName); using (var conn = provider.GetOpenConnection()) { DynamicParameters parameters = GetParameters(iEntity); int resultValue = DMSDbAccess.Execute(conn, attribute.Name, attribute.Name, parameters, null, 30, System.Data.CommandType.StoredProcedure); if (resultValue > 0) { return(true); } return(false); } }