/// <summary>
        /// single item insert with entity input
        /// </summary>
        /// <param name="input">to-be-inserted instance of entity class</param>
        public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode Insert(MSBuildLogsExtended.DataSourceEntities.BuildEventCode input)
        {
            log.Info(string.Format("{0}: Insert", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode  _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();
            _retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection();
            _retval.OriginalValue.Add(input);

            if (input != null)
            {
                MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode _LinqItem = MSBuildLogsExtended.EntityContracts.IBuildEventCodeHelper.Clone<MSBuildLogsExtended.DataSourceEntities.BuildEventCode, MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode>(input);
                this.LinqContext.BuildEventCode.Add(_LinqItem);
                this.LinqContext.SaveChanges();
                MSBuildLogsExtended.DataSourceEntities.BuildEventCode _Result = new MSBuildLogsExtended.DataSourceEntities.BuildEventCode();
                MSBuildLogsExtended.EntityContracts.IBuildEventCodeHelper.Copy<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode, MSBuildLogsExtended.DataSourceEntities.BuildEventCode>(_LinqItem, _Result);
                _retval.Result = new MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection();
                _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.DataAccessLayerMessageOfEntityCollectionBuildEventCode 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.DataAccessLayerMessageOfEntityCollectionBuildEventCode _retMessage = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();
            try
            {
                bool _Exists = _ExistsOfEntityOfAll(
				currentIndex
				,pageSize
				,queryOrderBySettingCollection
			);

                if (_Exists)
                {
                    IQueryable<MSBuildLogsExtended.DataSourceEntities.BuildEventCode> _Query = _GetQueryOfEntityOfAll(
				queryOrderBySettingCollection
			);

                    IEnumerable<MSBuildLogsExtended.DataSourceEntities.BuildEventCode> _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.BuildEventCodeCollection();
					_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>
        /// Batches the update with entity collection input.
        /// </summary>
        /// <param name="input">The input.</param>
        public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode BatchUpdate(MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection input)
        {
            log.Info(string.Format("{0}: BatchUpdate", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

			MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode  _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();
            _retval.OriginalValue = input;

            if (input != null)
            {
                List<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode> _ListOfLinq = new List<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode>();
                foreach (MSBuildLogsExtended.DataSourceEntities.BuildEventCode _ItemOfInput in input)
                {
                    MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode _LinqItem = GetLinqObjectByIdentifier(_ItemOfInput);
                    MSBuildLogsExtended.EntityContracts.IBuildEventCodeHelper.Copy<MSBuildLogsExtended.DataSourceEntities.BuildEventCode, MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode>(_ItemOfInput, _LinqItem);
                    _ListOfLinq.Add(_LinqItem);
                }
                this.LinqContext.SaveChanges();

                for (int i = 0; i < input.Count; i++)
                {
                    MSBuildLogsExtended.EntityContracts.IBuildEventCodeHelper.Copy
                        <
                            MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode, MSBuildLogsExtended.DataSourceEntities.BuildEventCode
                        >(_ListOfLinq[i], input[i]);
                }
            }
            log.Info(string.Format("{0}: BatchUpdate", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()));
			return _retval;
        }
        /// <summary>
        /// Batches the delete with entity collection input.
        /// </summary>
        /// <param name="input">The input.</param>
        public MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode BatchDelete(MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection input)
        {
            log.Info(string.Format("{0}: BatchDelete", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

			MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode  _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();
            _retval.OriginalValue = input;

            if (input != null)
            {
                List<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode> _ListOfLinq = new List<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode>();
                foreach (MSBuildLogsExtended.DataSourceEntities.BuildEventCode _ItemOfInput in input)
                {
                    MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode _LinqItem = GetLinqObjectByIdentifier(_ItemOfInput);	
					this.LinqContext.BuildEventCode.Remove(_LinqItem);
                }
                this.LinqContext.SaveChanges();
            }
            log.Info(string.Format("{0}: BatchDelete", 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.DataAccessLayerMessageOfEntityCollectionBuildEventCode BatchInsert(MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection input)
        {
            log.Info(string.Format("{0}: BatchInsert", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

			MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode  _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();
            _retval.OriginalValue = input;

            if (input != null && input.Count > 0)
            {
                try
                {
                    DataTable _DataTable = new DataTable();
				_DataTable.Columns.Add("Id", typeof(System.Int32));
				_DataTable.Columns.Add("EventCode", typeof(System.String));
				_DataTable.Columns.Add("Description", typeof(System.String));

                    foreach (MSBuildLogsExtended.DataSourceEntities.BuildEventCode _Item in input)
                    {
                        _DataTable.Rows.Add(new object[] { _Item.Id, _Item.EventCode, _Item.Description });
                    }

                    using (SqlBulkCopy s = new SqlBulkCopy(this.LinqContext.Database.Connection.ConnectionString))
                    {
                        s.DestinationTableName = "dbo.BuildEventCode";

					s.ColumnMappings.Add("Id", "Id");
					s.ColumnMappings.Add("EventCode", "EventCode");
					s.ColumnMappings.Add("Description", "Description");

                        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 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.DataAccessLayerMessageOfEntityCollectionBuildEventCode DeleteByIdentifier(MSBuildLogsExtended.DataSourceEntities.BuildEventCodeIdentifier id)
        {
            log.Info(string.Format("{0}: DeleteByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            
			MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode  _retval = new MSBuildLogsExtended.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionBuildEventCode();

            if (id != null)
            {
                MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode _LinqItem = GetLinqObjectByIdentifier(id);
                if (_LinqItem != null)
                {
					MSBuildLogsExtended.DataSourceEntities.BuildEventCode _Original = new MSBuildLogsExtended.DataSourceEntities.BuildEventCode();
					MSBuildLogsExtended.EntityContracts.IBuildEventCodeHelper.Copy<MSBuildLogsExtended.EntityFrameworkContext.BuildEventCode, MSBuildLogsExtended.DataSourceEntities.BuildEventCode>(_LinqItem, _Original);

					_retval.OriginalValue = new MSBuildLogsExtended.DataSourceEntities.BuildEventCodeCollection();
					_retval.OriginalValue.Add(_Original);

                    this.LinqContext.BuildEventCode.Remove(_LinqItem);
                    this.LinqContext.SaveChanges();
                }
            }
            log.Info(string.Format("{0}: DeleteByIdentifier", Framework.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()));
			return _retval;
        }