public virtual SystemProcessThread InsertSystemProcessThread(SystemProcessThread entity, string connectionString)
 {
     SystemProcessThread other = new SystemProcessThread();
     other = entity;
     if (entity.IsTransient())
     {
         string sql = @"Insert into SystemProcessThread (  [TenantId],[SystemProcessID]
         ,[Name]
         ,[SpringEntryName]
         ,[Description]
         ,[Enabled]
         ,[Continuous]
         ,[SleepTime]
         ,[AutoStart]
         ,[Status]
         ,[Message]
         ,[ScheduledTime]
         ,[StartRange]
         ,[EndRange]
         ,[LastSuccessfullyExecuted]
         ,[ContinuousDelay]
         ,[IsDeleted]
         ,[DisplayOrder]
         ,[Argument]
         ,[LastUpdateDate]
         ,[ExecutionTime]
         ,[EstimatedExecutionTime]
         ,[ShowUpdateInLog] )
         Values
         ( @TenantId
         , @SystemProcessID
         , @Name
         , @SpringEntryName
         , @Description
         , @Enabled
         , @Continuous
         , @SleepTime
         , @AutoStart
         , @Status
         , @Message
         , @ScheduledTime
         , @StartRange
         , @EndRange
         , @LastSuccessfullyExecuted
         , @ContinuousDelay
         , @IsDeleted
         , @DisplayOrder
         , @Argument
         , @LastUpdateDate
         , @ExecutionTime
         , @EstimatedExecutionTime
         , @ShowUpdateInLog );
         Select scope_identity()";
         SqlParameter[] parameterArray = new SqlParameter[]{
               new SqlParameter("@TenantId",entity.TenantId ?? (object)DBNull.Value)
             , new SqlParameter("@SystemProcessID",entity.SystemProcessId)
             , new SqlParameter("@Name",entity.Name)
             , new SqlParameter("@SpringEntryName",entity.SpringEntryName ?? (object)DBNull.Value)
             , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value)
             , new SqlParameter("@Enabled",entity.Enabled)
             , new SqlParameter("@Continuous",entity.Continuous)
             , new SqlParameter("@SleepTime",entity.SleepTime)
             , new SqlParameter("@AutoStart",entity.AutoStart)
             , new SqlParameter("@Status",entity.Status ?? (object)DBNull.Value)
             , new SqlParameter("@Message",entity.Message ?? (object)DBNull.Value)
             , new SqlParameter("@ScheduledTime",entity.ScheduledTime ?? (object)DBNull.Value)
             , new SqlParameter("@StartRange",entity.StartRange ?? (object)DBNull.Value)
             , new SqlParameter("@EndRange",entity.EndRange ?? (object)DBNull.Value)
             , new SqlParameter("@LastSuccessfullyExecuted",entity.LastSuccessfullyExecuted ?? (object)DBNull.Value)
             , new SqlParameter("@ContinuousDelay",entity.ContinuousDelay)
             , new SqlParameter("@IsDeleted",entity.IsDeleted)
             , new SqlParameter("@DisplayOrder",entity.DisplayOrder)
             , new SqlParameter("@Argument",entity.Argument ?? (object)DBNull.Value)
             , new SqlParameter("@LastUpdateDate",entity.LastUpdateDate ?? (object)DBNull.Value)
             , new SqlParameter("@ExecutionTime",entity.ExecutionTime ?? (object)DBNull.Value)
             , new SqlParameter("@EstimatedExecutionTime",entity.EstimatedExecutionTime ?? (object)DBNull.Value)
             , new SqlParameter("@ShowUpdateInLog",entity.ShowUpdateInLog ?? (object)DBNull.Value)};
         var identity = SqlHelper.ExecuteScalar(string.IsNullOrEmpty(connectionString) ? this.ConnectionString : connectionString, CommandType.Text, sql, parameterArray);
         if (identity == DBNull.Value) throw new DataException("Identity column was null as a result of the insert operation.");
         return GetSystemProcessThread(Convert.ToInt32(identity),connectionString);
     }
     return entity;
 }
 public virtual SystemProcessThread UpdateSystemProcessThread(SystemProcessThread entity)
 {
     if (entity.IsTransient()) return entity;
     SystemProcessThread other = GetSystemProcessThread(entity.SystemProcessThreadId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update SystemProcessThread set  [SystemProcessID]=@SystemProcessID
                     , [Name]=@Name
                     , [SpringEntryName]=@SpringEntryName
                     , [Description]=@Description
                     , [Enabled]=@Enabled
                     , [Continuous]=@Continuous
                     , [SleepTime]=@SleepTime
                     , [AutoStart]=@AutoStart
                     , [Status]=@Status
                     , [Message]=@Message
                     , [ScheduledTime]=@ScheduledTime
                     , [StartRange]=@StartRange
                     , [EndRange]=@EndRange
                     , [LastSuccessfullyExecuted]=@LastSuccessfullyExecuted
                     , [ContinuousDelay]=@ContinuousDelay
                     , [IsDeleted]=@IsDeleted
                     , [DisplayOrder]=@DisplayOrder
                     , [Argument]=@Argument
                     , [LastUpdateDate]=@LastUpdateDate
                     , [ExecutionTime]=@ExecutionTime
                     , [EstimatedExecutionTime]=@EstimatedExecutionTime
                     , [ShowUpdateInLog]=@ShowUpdateInLog
                     , [TenantId]=@TenantId
                      where SystemProcessThreadID=@SystemProcessThreadID";
     SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@SystemProcessID",entity.SystemProcessId)
             , new SqlParameter("@Name",entity.Name)
             , new SqlParameter("@SpringEntryName",entity.SpringEntryName ?? (object)DBNull.Value)
             , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value)
             , new SqlParameter("@Enabled",entity.Enabled)
             , new SqlParameter("@Continuous",entity.Continuous)
             , new SqlParameter("@SleepTime",entity.SleepTime)
             , new SqlParameter("@AutoStart",entity.AutoStart)
             , new SqlParameter("@Status",entity.Status ?? (object)DBNull.Value)
             , new SqlParameter("@Message",entity.Message ?? (object)DBNull.Value)
             , new SqlParameter("@ScheduledTime",entity.ScheduledTime ?? (object)DBNull.Value)
             , new SqlParameter("@StartRange",entity.StartRange ?? (object)DBNull.Value)
             , new SqlParameter("@EndRange",entity.EndRange ?? (object)DBNull.Value)
             , new SqlParameter("@LastSuccessfullyExecuted",entity.LastSuccessfullyExecuted ?? (object)DBNull.Value)
             , new SqlParameter("@ContinuousDelay",entity.ContinuousDelay)
             , new SqlParameter("@IsDeleted",entity.IsDeleted)
             , new SqlParameter("@DisplayOrder",entity.DisplayOrder)
             , new SqlParameter("@Argument",entity.Argument ?? (object)DBNull.Value)
             , new SqlParameter("@LastUpdateDate",entity.LastUpdateDate ?? (object)DBNull.Value)
             , new SqlParameter("@ExecutionTime",entity.ExecutionTime ?? (object)DBNull.Value)
             , new SqlParameter("@EstimatedExecutionTime",entity.EstimatedExecutionTime ?? (object)DBNull.Value)
             , new SqlParameter("@ShowUpdateInLog",entity.ShowUpdateInLog ?? (object)DBNull.Value)
             , new SqlParameter("@TenantId",entity.TenantId ?? (object)DBNull.Value)
             , new SqlParameter("@SystemProcessThreadID",entity.SystemProcessThreadId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetSystemProcessThread(entity.SystemProcessThreadId);
 }