/// <summary> /// single item insert with entity input /// </summary> /// <param name="input">to-be-inserted instance of entity class</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog Insert(MSBuildLogsExtended.DataSourceEntities.BuildLog input) { log.Info(string.Format("{0}: Insert", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.OriginalValue.Add(input); if (input != null) { MSBuildLogsExtended.EntityFrameworkContext.BuildLog _LinqItem = MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Clone<MSBuildLogsExtended.DataSourceEntities.BuildLog, MSBuildLogsExtended.EntityFrameworkContext.BuildLog>(input); this.LinqContext.BuildLog.Add(_LinqItem); this.LinqContext.SaveChanges(); MSBuildLogsExtended.DataSourceEntities.BuildLog _Result = new MSBuildLogsExtended.DataSourceEntities.BuildLog(); MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy<MSBuildLogsExtended.EntityFrameworkContext.BuildLog, MSBuildLogsExtended.DataSourceEntities.BuildLog>(_LinqItem, _Result); _retval.Result = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.Result.Add(_Result); } log.Info(string.Format("{0}: Insert", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// The return value of this set of query is: <see cref="ASPNETDB_CACHE.DataSourceEntities.AspNet_SqlCacheTablesForChangeNotification"/> /// The key query criteria of this set of query is: Common. /// Common query set is a built-in set of query criteria, which will query all foreign keys, string/text value, and range of datatime /// There are 7 methods, 1 internal, 2 private and 4 public, for one set of return value and query criteria: /// internal _GetQueryOfEntityOf...(...) gives the Linq Query /// private _ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// private _GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// public GetSingleOfEntityOf...(...) returns the first record if there is any records meets Query Criteria, otherwise null /// *public GetCollectionOfEntityOf...(...) returns all records if there is any records meets Query Criteria, otherwise null /// </summary> /// <param name="currentIndex">current page index</param> /// <param name="pageSize">page size</param> /// <param name="queryOrderBySettingCollection">query OrderBy setting</param> /// <returns>result message with entity collection</returns> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog GetCollectionOfEntityOfCommon( Framework.EntityContracts.QuerySystemInt64EqualsCriteria criteriaOfIdOfBuild_B1_1OfCommonOfCommonOfCommon ,Framework.EntityContracts.QuerySystemInt32EqualsCriteria criteriaOfIdOfSolution_S1_1OfCommonOfCommonOfCommon ,Framework.EntityContracts.QuerySystemInt32EqualsCriteria criteriaOfIdOfBuildEventCode_B2_1OfCommonOfCommonOfCommon ,Framework.EntityContracts.QuerySystemStringContainsCriteria criteriaOfMessageOftOfCommonOfCommonOfCommon ,Framework.EntityContracts.QuerySystemDateTimeRangeCriteria criteriaOfEventTimeOftOfCommonOfCommonOfCommon ,int currentIndex ,int pageSize ,Framework.EntityContracts.QueryOrderBySettingCollection queryOrderBySettingCollection ) { log.Info(string.Format("{0}: GetCollectionOfEntityOfCommon", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retMessage = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); try { bool _Exists = _ExistsOfEntityOfCommon( criteriaOfIdOfBuild_B1_1OfCommonOfCommonOfCommon ,criteriaOfIdOfSolution_S1_1OfCommonOfCommonOfCommon ,criteriaOfIdOfBuildEventCode_B2_1OfCommonOfCommonOfCommon ,criteriaOfMessageOftOfCommonOfCommonOfCommon ,criteriaOfEventTimeOftOfCommonOfCommonOfCommon ,currentIndex ,pageSize ,queryOrderBySettingCollection ); if (_Exists) { IQueryable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _Query = _GetQueryOfEntityOfCommon( criteriaOfIdOfBuild_B1_1OfCommonOfCommonOfCommon ,criteriaOfIdOfSolution_S1_1OfCommonOfCommonOfCommon ,criteriaOfIdOfBuildEventCode_B2_1OfCommonOfCommonOfCommon ,criteriaOfMessageOftOfCommonOfCommonOfCommon ,criteriaOfEventTimeOftOfCommonOfCommonOfCommon ,queryOrderBySettingCollection ); IEnumerable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _retval; if (currentIndex == -1 || pageSize == -1) { _retval = _Query; } else { _retval = _Query.Skip(currentIndex).Take(pageSize); } _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Success; _retMessage.Result = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retMessage.Result.AddRange(_retval); } else { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.SuccessButNoResult; _retMessage.Result = null; } } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Fail; _retMessage.Result = null; _retMessage.Message = ex.Message; log.Error(string.Format("{0}: GetCollectionOfEntityOfCommon", Framework.LoggingOptions.Data_Access_Layer_Process_Failed.ToString()), ex); } log.Info(string.Format("{0}: GetCollectionOfEntityOfCommon", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retMessage; }
/// <summary> /// Batches the delete with entity collection input. /// </summary> /// <param name="input">The input.</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog BatchDelete(MSBuildLogsExtended.DataSourceEntities.BuildLogCollection input) { log.Info(string.Format("{0}: BatchDelete", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = input; if (input != null) { List<MSBuildLogsExtended.EntityFrameworkContext.BuildLog> _ListOfLinq = new List<MSBuildLogsExtended.EntityFrameworkContext.BuildLog>(); foreach (MSBuildLogsExtended.DataSourceEntities.BuildLog _ItemOfInput in input) { MSBuildLogsExtended.EntityFrameworkContext.BuildLog _LinqItem = GetLinqObjectByIdentifier(_ItemOfInput); this.LinqContext.BuildLog.Remove(_LinqItem); } this.LinqContext.SaveChanges(); } log.Info(string.Format("{0}: BatchDelete", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// Batches the update with entity collection input. /// </summary> /// <param name="input">The input.</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog BatchUpdate(MSBuildLogsExtended.DataSourceEntities.BuildLogCollection input) { log.Info(string.Format("{0}: BatchUpdate", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = input; if (input != null) { List<MSBuildLogsExtended.EntityFrameworkContext.BuildLog> _ListOfLinq = new List<MSBuildLogsExtended.EntityFrameworkContext.BuildLog>(); foreach (MSBuildLogsExtended.DataSourceEntities.BuildLog _ItemOfInput in input) { MSBuildLogsExtended.EntityFrameworkContext.BuildLog _LinqItem = GetLinqObjectByIdentifier(_ItemOfInput); MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy<MSBuildLogsExtended.DataSourceEntities.BuildLog, MSBuildLogsExtended.EntityFrameworkContext.BuildLog>(_ItemOfInput, _LinqItem); _ListOfLinq.Add(_LinqItem); } this.LinqContext.SaveChanges(); for (int i = 0; i < input.Count; i++) { MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy < MSBuildLogsExtended.EntityFrameworkContext.BuildLog, MSBuildLogsExtended.DataSourceEntities.BuildLog >(_ListOfLinq[i], input[i]); } } log.Info(string.Format("{0}: BatchUpdate", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// single item delete by identifier with entity identifier input /// </summary> /// <param name="id">delete the item if its identifier equals to this parameter</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog DeleteByIdentifier(MSBuildLogsExtended.DataSourceEntities.BuildLogIdentifier id) { log.Info(string.Format("{0}: DeleteByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); if (id != null) { MSBuildLogsExtended.EntityFrameworkContext.BuildLog _LinqItem = GetLinqObjectByIdentifier(id); if (_LinqItem != null) { MSBuildLogsExtended.DataSourceEntities.BuildLog _Original = new MSBuildLogsExtended.DataSourceEntities.BuildLog(); MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy<MSBuildLogsExtended.EntityFrameworkContext.BuildLog, MSBuildLogsExtended.DataSourceEntities.BuildLog>(_LinqItem, _Original); _retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.OriginalValue.Add(_Original); this.LinqContext.BuildLog.Remove(_LinqItem); this.LinqContext.SaveChanges(); } } log.Info(string.Format("{0}: DeleteByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// Batches insert with entity collection input. /// </summary> /// <param name="input">The input.</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog BatchInsert(MSBuildLogsExtended.DataSourceEntities.BuildLogCollection input) { log.Info(string.Format("{0}: BatchInsert", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = input; if (input != null && input.Count > 0) { try { DataTable _DataTable = new DataTable(); _DataTable.Columns.Add("Id", typeof(System.Int64)); _DataTable.Columns.Add("BuildId", typeof(System.Int64)); _DataTable.Columns.Add("BuildEventCodeId", typeof(System.Int32)); _DataTable.Columns.Add("Message", typeof(System.String)); _DataTable.Columns.Add("EventTime", typeof(System.DateTime)); foreach (MSBuildLogsExtended.DataSourceEntities.BuildLog _Item in input) { _DataTable.Rows.Add(new object[] { _Item.Id, _Item.BuildId, _Item.BuildEventCodeId, _Item.Message, _Item.EventTime }); } using (SqlBulkCopy s = new SqlBulkCopy(this.LinqContext.Database.Connection.ConnectionString)) { s.DestinationTableName = "dbo.BuildLog"; s.ColumnMappings.Add("Id", "Id"); s.ColumnMappings.Add("BuildId", "BuildId"); s.ColumnMappings.Add("BuildEventCodeId", "BuildEventCodeId"); s.ColumnMappings.Add("Message", "Message"); s.ColumnMappings.Add("EventTime", "EventTime"); s.NotifyAfter = 10000; s.WriteToServer(_DataTable); s.Close(); } } catch (Exception ex) { log.Error(string.Format("{0}: Insert", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()), ex); } } log.Info(string.Format("{0}: BatchInsert", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// The return value of this set of query is: <see cref="ASPNETDB_CACHE.DataSourceEntities.AspNet_SqlCacheTablesForChangeNotification"/> /// The key query criteria of this set of query is: Common. /// Common query set is a built-in set of query criteria, which will query all foreign keys, string/text value, and range of datatime /// There are 7 methods, 1 internal, 2 private and 4 public, for one set of return value and query criteria: /// internal _GetQueryOfEntityOf...(...) gives the Linq Query /// private _ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// private _GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// public GetSingleOfEntityOf...(...) returns the first record if there is any records meets Query Criteria, otherwise null /// *public GetCollectionOfEntityOf...(...) returns all records if there is any records meets Query Criteria, otherwise null /// </summary> /// <param name="currentIndex">current page index</param> /// <param name="pageSize">page size</param> /// <param name="queryOrderBySettingCollection">query OrderBy setting</param> /// <returns>result message with entity collection</returns> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog GetCollectionOfEntityOfAll( int currentIndex ,int pageSize ,Framework.EntityContracts.QueryOrderBySettingCollection queryOrderBySettingCollection ) { log.Info(string.Format("{0}: GetCollectionOfEntityOfAll", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retMessage = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); try { bool _Exists = _ExistsOfEntityOfAll( currentIndex ,pageSize ,queryOrderBySettingCollection ); if (_Exists) { IQueryable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _Query = _GetQueryOfEntityOfAll( queryOrderBySettingCollection ); IEnumerable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _retval; if (currentIndex == -1 || pageSize == -1) { _retval = _Query; } else { _retval = _Query.Skip(currentIndex).Take(pageSize); } _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Success; _retMessage.Result = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retMessage.Result.AddRange(_retval); } else { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.SuccessButNoResult; _retMessage.Result = null; } } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Fail; _retMessage.Result = null; _retMessage.Message = ex.Message; log.Error(string.Format("{0}: GetCollectionOfEntityOfAll", Framework.LoggingOptions.Data_Access_Layer_Process_Failed.ToString()), ex); } log.Info(string.Format("{0}: GetCollectionOfEntityOfAll", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retMessage; }
/// <summary> /// single item update with entity input /// </summary> /// <param name="input">to-be-updated instance of entity class</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog Update(MSBuildLogsExtended.DataSourceEntities.BuildLog input) { log.Info(string.Format("{0}: Update", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.OriginalValue.Add(input); if (input != null) { MSBuildLogsExtended.LinqToSqlContexts.BuildLog _LinqItem = GetLinqObjectByIdentifier(input); if (_LinqItem != null) { //MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy<MSBuildLogsExtended.DataSourceEntities.BuildLog, MSBuildLogsExtended.LinqToSqlContexts.BuildLog>(input, _LinqItem); _LinqItem.Id = input.Id; _LinqItem.BuildId = input.BuildId; _LinqItem.BuildEventCodeId = input.BuildEventCodeId; _LinqItem.Message = input.Message; _LinqItem.EventTime = input.EventTime; this.LinqContext.SubmitChanges(); MSBuildLogsExtended.DataSourceEntities.BuildLog _Result = new MSBuildLogsExtended.DataSourceEntities.BuildLog(); MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy<MSBuildLogsExtended.LinqToSqlContexts.BuildLog, MSBuildLogsExtended.DataSourceEntities.BuildLog>(_LinqItem, _Result); _retval.Result = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.Result.Add(_Result); } } log.Info(string.Format("{0}: Update", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); return _retval; }
/// <summary> /// The return value of this set of query is: <see cref="ASPNETDB_CACHE.DataSourceEntities.AspNet_SqlCacheTablesForChangeNotification"/> /// The key query criteria of this set of query is: Common. /// Common query set is a built-in set of query criteria, which will query all foreign keys, string/text value, and range of datatime /// There are 7 methods, 1 internal, 2 private and 4 public, for one set of return value and query criteria: /// internal _GetQueryOfEntityOf...(...) gives the Linq Query /// private _ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// private _GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public GetCountOfEntityOf...(...) returns count if there is any records meets Query Criteria, otherwise 0 /// public ExistsOfEntityOf...(...) returns true if there is any records meets Query Criteria, otherwise false /// public GetSingleOfEntityOf...(...) returns the first record if there is any records meets Query Criteria, otherwise null /// *public GetCollectionOfEntityOf...(...) returns all records if there is any records meets Query Criteria, otherwise null /// </summary> /// <param name="currentIndex">current page index</param> /// <param name="pageSize">page size</param> /// <param name="queryOrderBySettingCollection">query OrderBy setting</param> /// <returns>result message with entity collection</returns> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog GetCollectionOfEntityOfByIdentifier( Framework.EntityContracts.QuerySystemInt64EqualsCriteria criteriaOfIdOftOfByIdentifierOfByIdentifierOfByIdentifier ,int currentIndex ,int pageSize ,Framework.EntityContracts.QueryOrderBySettingCollection queryOrderBySettingCollection ) { log.Info(string.Format("{0}: GetCollectionOfEntityOfByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retMessage = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); try { bool _Exists = _ExistsOfEntityOfByIdentifier( criteriaOfIdOftOfByIdentifierOfByIdentifierOfByIdentifier ,currentIndex ,pageSize ,queryOrderBySettingCollection ); if (_Exists) { IQueryable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _Query = _GetQueryOfEntityOfByIdentifier( criteriaOfIdOftOfByIdentifierOfByIdentifierOfByIdentifier ,queryOrderBySettingCollection ); IEnumerable<MSBuildLogsExtended.DataSourceEntities.BuildLog> _retval; if (currentIndex == -1 || pageSize == -1) { _retval = _Query; } else { _retval = _Query.Skip(currentIndex).Take(pageSize); } _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Success; _retMessage.Result = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retMessage.Result.AddRange(_retval); _retMessage.QueryPagingResult = new Framework.EntityContracts.QueryPagingResult { RecordCountOfCurrentPage = _retval.Count(), CountOfRecords = _Query.Count(), CurrentIndexOfStartRecord = currentIndex, PageSize = pageSize, }; } else { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.SuccessButNoResult; _retMessage.Result = null; } } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.DataSourceEntities.DataAccessLayerMessageStatus.Fail; _retMessage.Result = null; _retMessage.Message = ex.Message; log.Error(string.Format("{0}: GetCollectionOfEntityOfByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Failed.ToString()), ex); } log.Info(string.Format("{0}: GetCollectionOfEntityOfByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retMessage; }
/// <summary> /// Batches insert with entity collection input. /// </summary> /// <param name="input">The input.</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog BatchInsert(MSBuildLogsExtended.DataSourceEntities.BuildLogCollection input) { log.Info(string.Format("{0}: BatchInsert", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); #region insert row-by-row to be removed /* if (input != null) { List<MSBuildLogsExtended.LinqToSqlContexts.BuildLog> _ListOfLinq = MSBuildLogsExtended.EntityContracts.IBuildLogHelper.CloneCollection < MSBuildLogsExtended.DataSourceEntities.BuildLogCollection, List<MSBuildLogsExtended.LinqToSqlContexts.BuildLog>, MSBuildLogsExtended.DataSourceEntities.BuildLog, MSBuildLogsExtended.LinqToSqlContexts.BuildLog >(input); this.LinqContext.BuildLog.InsertAllOnSubmit<MSBuildLogsExtended.LinqToSqlContexts.BuildLog>(_ListOfLinq); this.LinqContext.SubmitChanges(); for (int i = 0; i < input.Count; i++) { MSBuildLogsExtended.EntityContracts.IBuildLogHelper.Copy < MSBuildLogsExtended.LinqToSqlContexts.BuildLog, MSBuildLogsExtended.DataSourceEntities.BuildLog >(_ListOfLinq[i], input[i]); } } */ #endregion insert row-by-row to be removed MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = input; if (input != null && input.Count > 0) { try { DataTable _DataTable = new DataTable(); _DataTable.Columns.Add("Id", typeof(System.Int64)); _DataTable.Columns.Add("BuildId", typeof(System.Int64)); _DataTable.Columns.Add("BuildEventCodeId", typeof(System.Int32)); _DataTable.Columns.Add("Message", typeof(System.String)); _DataTable.Columns.Add("EventTime", typeof(System.DateTime)); foreach (MSBuildLogsExtended.DataSourceEntities.BuildLog _Item in input) { _DataTable.Rows.Add(new object[] { _Item.Id, _Item.BuildId, _Item.BuildEventCodeId, _Item.Message, _Item.EventTime }); } using (SqlBulkCopy s = new SqlBulkCopy(this.LinqContext.Connection.ConnectionString)) { s.DestinationTableName = "dbo.BuildLog"; s.ColumnMappings.Add("Id", "Id"); s.ColumnMappings.Add("BuildId", "BuildId"); s.ColumnMappings.Add("BuildEventCodeId", "BuildEventCodeId"); s.ColumnMappings.Add("Message", "Message"); s.ColumnMappings.Add("EventTime", "EventTime"); s.NotifyAfter = 10000; s.WriteToServer(_DataTable); s.Close(); } } catch (Exception ex) { log.Error(string.Format("{0}: Insert", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()), ex); } } log.Info(string.Format("{0}: BatchInsert", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }
/// <summary> /// single item deletion with entity input /// </summary> /// <param name="input">item to be deleted</param> public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog Delete(MSBuildLogsExtended.DataSourceEntities.BuildLog input) { log.Info(string.Format("{0}: Delete", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildLog(); _retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildLogCollection(); _retval.OriginalValue.Add(input); if (input != null) { MSBuildLogsExtended.LinqToSqlContexts.BuildLog _LinqItem = GetLinqObjectByIdentifier(input); if (_LinqItem != null) { this.LinqContext.BuildLog.DeleteOnSubmit(_LinqItem); this.LinqContext.SubmitChanges(); } } log.Info(string.Format("{0}: Delete", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return _retval; }