public int Function_Group_Insert_Batch(Function_GroupInfo[] p_arr) { try { List <Function_GroupInfo> p_lst = new List <Function_GroupInfo>(); for (int i = 0; i < p_arr.Length; i++) { Function_GroupInfo item = p_arr[i]; p_lst.Add(item); } Function_Group_DA _Function_Group_DA = new Function_Group_DA(); return(_Function_Group_DA.Function_Group_Insert_Batch(p_lst)); } catch (Exception ex) { ErrorLog.log.Error(ex.ToString()); return(-1); } }
public void Function_Group_Insert_Batch(ArrayList arr, decimal type) { try { List <Function_GroupInfo> _list = new List <Function_GroupInfo>(); for (int i = 0; i < arr.Count; i++) { FunctionsInfo item = (FunctionsInfo)arr[i]; Function_GroupInfo _Function_GroupInfo = new Function_GroupInfo(); _Function_GroupInfo.user_type = type; _Function_GroupInfo.functionid = item.id; _list.Add(_Function_GroupInfo); } string strConn = CommonData.ConnectionString; using (SqlConnection conn = new SqlConnection(strConn)) { if (conn.State == ConnectionState.Closed) { conn.Open(); } var bulkCopy = new SqlBulkCopy(conn); bulkCopy.DestinationTableName = "Function_Group"; bulkCopy.ColumnMappings.Add("user_type", "user_type"); bulkCopy.ColumnMappings.Add("functionid", "functionid"); using (var datareader = new ObjectDataReader <Function_GroupInfo>(_list)) { bulkCopy.WriteToServer(datareader); } } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
public void Function_Group_Insert_Batch(ArrayList p_arr, decimal p_group_id) { try { List <Function_GroupInfo> _list = new List <Function_GroupInfo>(); Function_GroupInfo[] _arr = new Function_GroupInfo[p_arr.Count]; for (int i = 0; i < p_arr.Count; i++) { FunctionsInfo item = (FunctionsInfo)p_arr[i]; Function_GroupInfo _Function_GroupInfo = new Function_GroupInfo(); _Function_GroupInfo.Group_Id = p_group_id; _Function_GroupInfo.Functionid = item.id; _list.Add(_Function_GroupInfo); _arr[i] = _Function_GroupInfo; } CommonData.c_serviceWCF.Function_Group_Insert_Batch(_arr); } catch (Exception ex) { ErrorLog.log.Error(ex.ToString()); } }