public bool SyncJobExists(string jobName, string id) { SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } // TODO: Change sql to SELECT COUNT(*)? string cmdText = "SELECT * FROM " + SYNCJOB_TABLE + " WHERE " + COL_SYNCJOB_NAME + " = @profileName AND " + COL_SYNCJOB_ID + " <> @id"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@profileName", System.Data.DbType.String) { Value = jobName }); paramList.Add(new SqliteParameter("@id", System.Data.DbType.String) { Value = id }); bool found = false; db.ExecuteReader(cmdText, paramList, reader => { found = true; return; } ); return(found); } }
public override bool Update(SyncJob job) { if (this.SyncJobExists(job.Name, job.ID)) { throw new SyncJobNameExistException(String.Format(m_ResourceManager.GetString("err_syncjobCreated"), job.Name)); } SQLiteSyncSourceProvider provider = (SQLiteSyncSourceProvider)SyncClient.GetSyncSourceProvider(job.IntermediaryStorage.Path); if (provider.GetSyncSourceCount() > 2) { throw new SyncSourcesNumberExceededException(m_ResourceManager.GetString("err_onlyTwoSyncSourceFolders")); } // Update a profile requires update 2 tables at the same time, // If one update on a table fails, the total update action must fail too. string updateProfileText = "UPDATE " + SYNCJOB_TABLE + " SET " + COL_METADATA_SOURCE_LOCATION + " = @mdSource, " + COL_SYNCJOB_NAME + " = @name WHERE " + COL_SYNCJOB_ID + " = @id;"; SqliteParameterCollection paramList = new SqliteParameterCollection(); // Add parameters for 1st Update statement paramList.Add(new SqliteParameter("@mdSource", System.Data.DbType.String) { Value = job.IntermediaryStorage.Path }); paramList.Add(new SqliteParameter("@name", System.Data.DbType.String) { Value = job.Name }); paramList.Add(new SqliteParameter("@id", System.Data.DbType.String) { Value = job.ID }); SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, DATABASE_NAME))); } SqliteTransaction transaction = (SqliteTransaction)con.BeginTransaction(); try { SQLiteSyncSourceProvider.Update(job.SyncSource, con); db.ExecuteNonQuery(updateProfileText, paramList); transaction.Commit(); return(true); } catch (Exception) { transaction.Rollback(); throw; } } }
public override bool Delete(SyncJob job) { SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, DATABASE_NAME))); } SqliteParameterCollection paramList = new SqliteParameterCollection(); string cmdText = "DELETE FROM " + SyncSource.DATASOURCE_INFO_TABLE + " WHERE " + SyncSource.SOURCE_ID + " = @sid;"; paramList.Add(new SqliteParameter("@sid", System.Data.DbType.String) { Value = job.SyncSource.ID }); cmdText += "DELETE FROM " + SYNCJOB_TABLE + " WHERE " + COL_SYNCJOB_ID + " = @pid"; paramList.Add(new SqliteParameter("@pid", System.Data.DbType.String) { Value = job.ID }); db.ExecuteNonQuery(cmdText, paramList); } return(true); }
public override FolderMetadata LoadFolderMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var folderMetadata = new FolderMetadata(currId, this.RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "SELECT * FROM " + Configuration.TLB_FOLDERMETADATA + " WHERE " + Configuration.COL_SOURCE_ID + opt + " @sourceId"; var paramList = new SqliteParameterCollection { new SqliteParameter("@sourceId", DbType.String) { Value = currId } }; db.ExecuteReader(cmdText, paramList, reader => folderMetadata.FolderMetadataItems.Add( new FolderMetadataItem( (string)reader[Configuration.COL_SOURCE_ID], (string)reader[Configuration.COL_FOLDER_RELATIVE_PATH], (int)reader[Configuration.COL_IS_FOLDER_EMPTY]))); } return(folderMetadata); }
public override bool Delete(IList <SyncAction> actions) { SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "DELETE FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_ACTION_ID + " = @id"; SqliteParameterCollection paramList = new SqliteParameterCollection(); foreach (SyncAction action in actions) { paramList.Clear(); paramList.Add(new SqliteParameter("@id", DbType.Int32) { Value = action.ActionId }); db.ExecuteNonQuery(cmdText, paramList); } } return(true); }
/// <summary> /// Update details of a sync source /// </summary> /// <param name="source"></param> /// <returns></returns> public override bool Update(SyncSource source) { SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "UPDATE " + Configuration.TBL_DATASOURCE_INFO + " SET " + Configuration.COL_SOURCE_ABSOLUTE_PATH + " = @path WHERE " + Configuration.COL_SOURCE_ID + " = @id"; SqliteParameterCollection paramList = new SqliteParameterCollection { new SqliteParameter("@id", DbType.String) { Value = source.ID }, new SqliteParameter("@path", DbType.String) { Value = source.Path } }; db.ExecuteNonQuery(cmdText, false); } return(true); }
public override bool Delete(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "DELETE FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + " " + opt + " @id"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@id", System.Data.DbType.Int32) { Value = sourceID }); db.ExecuteNonQuery(cmdText, paramList); } return(true); }
private static bool InsertCreateAction(CreateAction createAction, SqliteConnection con) { using (SqliteCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO " + Configuration.TBL_ACTION + " ( " + Configuration.COL_CHANGE_IN + "," + Configuration.COL_ACTION_TYPE + "," + Configuration.COL_NEW_RELATIVE_PATH + "," + Configuration.COL_NEW_HASH + ") VALUES (@changeIn, @action, @newPath, @newHash)"; SqliteParameterCollection paramList = new SqliteParameterCollection(); cmd.Parameters.Add(new SqliteParameter("@changeIn", System.Data.DbType.String) { Value = createAction.SourceID }); cmd.Parameters.Add(new SqliteParameter("@action", System.Data.DbType.Int32) { Value = createAction.ChangeType }); cmd.Parameters.Add(new SqliteParameter("@newPath", System.Data.DbType.String) { Value = createAction.RelativeFilePath }); cmd.Parameters.Add(new SqliteParameter("@newHash", System.Data.DbType.String) { Value = createAction.FileHash }); cmd.ExecuteNonQuery(); return(true); } }
public override FileMetaData LoadFileMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var mData = new FileMetaData(currId, RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = string.Format("SELECT * FROM {0} WHERE {1}{2} @sourceId", Configuration.TBL_METADATA, Configuration.COL_SOURCE_ID, opt); var paramList = new SqliteParameterCollection { new SqliteParameter("@sourceId", DbType.String) { Value = currId } }; db.ExecuteReader(cmdText, paramList, reader => mData.MetaDataItems.Add(new FileMetaDataItem( (string)reader[Configuration.COL_SOURCE_ID], (string)reader[Configuration.COL_RELATIVE_PATH], (string)reader[Configuration.COL_HASH_CODE], (DateTime)reader[Configuration.COL_LAST_MODIFIED_TIME], Convert.ToUInt32(reader[Configuration.COL_NTFS_ID1]), Convert.ToUInt32(reader[Configuration.COL_NTFS_ID2])))); } return(mData); }
public override IList <SyncAction> Load(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; IList <SyncAction> actions = new List <SyncAction>(); SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "SELECT * FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + opt + " @sourceId"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@sourceId", System.Data.DbType.String) { Value = sourceID }); db.ExecuteReader(cmdText, paramList, reader => { ChangeType actionType = (ChangeType)reader[Configuration.COL_ACTION_TYPE]; if (actionType == ChangeType.DELETED) { DeleteAction delAction = new DeleteAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(delAction); } else if (actionType == ChangeType.NEWLY_CREATED) { CreateAction createAction = new CreateAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_NEW_HASH]); actions.Add(createAction); } else if (actionType == ChangeType.RENAMED) { RenameAction renameAction = new RenameAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(renameAction); } } ); } return(actions); }
public void process(string filename, string sql, SqliteParameterCollection sqlpram) { Parameters = sqlpram; pathName(filename); db_conntion(null); commandstring(sql); close(); }
public static void AddIdParameter ( this SqliteParameterCollection source, ITasqueCore item) { if (source == null) throw new NullReferenceException ("source"); if (item == null) throw new ArgumentNullException ("item"); source.AddWithValue ("@id", int.Parse (item.Id)); }
private SqliteParameterCollection DataSql_Parameters(string[] data) { SqliteCommand SqliteCommand = new SqliteCommand(); SqliteParameterCollection ReturnParamter = SqliteCommand.Parameters; ReturnParamter.AddWithValue(LibraryWords.Row, data[0]); ReturnParamter.AddWithValue(LibraryWords.Row + 1.ToString(), data[1]); return(ReturnParamter); }
/// <summary> /// Executes a SQL statement against the SQLite connection /// and returns the number of rows affected. /// </summary> /// <param name="cmdText">SQL query string.</param> /// <param name="paramsList">Parameters list.</param> /// <param name="atomic">Whether query is executed as a transaction.</param> /// <returns> /// For UPDATE, INSERT, and DELETE statements, the return value is the /// number of rows affected by the command. /// For all other types of statements, the return value is -1. /// </returns> public int ExecuteNonQuery(string cmdText, SqliteParameterCollection paramsList) { int affectedRows = 0; using (SqliteCommand cmd = GetCommand(cmdText, paramsList)) { affectedRows = cmd.ExecuteNonQuery(); } return(affectedRows); }
/// <summary> /// Executes the query and returns the first column of the first row in the result set returned by the query. /// All other columns and rows are ignored. /// </summary> /// <param name="cmdText">SQL query string.</param> /// /// <param name="paramsList">Parameters list.</param> /// <returns>The first column of the first row in the result set.</returns> public string ExecuteScalar(string cmdText, SqliteParameterCollection paramsList) { string retStr = null; using (SqliteCommand cmd = GetCommand(cmdText, paramsList)) { retStr = cmd.ExecuteScalar().ToString(); } return(retStr); }
/// <summary> /// null verification /// </summary> public static SqliteParameter AddWithNullableValue(this SqliteParameterCollection collection, string parameterName, object value) { if (value == null) { return(collection.AddWithValue(parameterName, DBNull.Value)); } else { return(collection.AddWithValue(parameterName, value)); } }
void SpecifyParameter(SqliteParameterCollection parameters, string parameterName, object value) { parameters[parameterName].ResetDbType(); parameters[parameterName].Value = value; var isSpecifiedName = parameterName + "IsSpecified"; if (parameters.Contains(isSpecifiedName)) { parameters[isSpecifiedName].Value = true; } }
private SqliteParameterCollection DataSql_Parameters(string String) { SqliteCommand SqliteCommand = new SqliteCommand(); SqliteParameterCollection ReturnParamter = SqliteCommand.Parameters; ReturnParamter.AddWithValue(LibraryWords.Row, String); // ReturnParamter.AddWithValue("@port", field2.Text); return(ReturnParamter); }
public override bool Update(IList <FileMetaDataItem> items) { SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } SqliteTransaction trasaction = (SqliteTransaction)con.BeginTransaction(); try { foreach (FileMetaDataItem item in items) { string cmdText = "UPDATE " + Configuration.TBL_METADATA + " SET " + Configuration.COL_HASH_CODE + " = @hash, " + Configuration.COL_LAST_MODIFIED_TIME + " = @lmf" + " WHERE " + Configuration.COL_RELATIVE_PATH + " = @rel AND " + Configuration.COL_SOURCE_ID + " = @sourceId"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@hash", DbType.String) { Value = item.HashCode }); paramList.Add(new SqliteParameter("@lmf", DbType.DateTime) { Value = item.LastModifiedTime }); paramList.Add(new SqliteParameter("@rel", DbType.String) { Value = item.RelativePath }); paramList.Add(new SqliteParameter("@sourceId", DbType.String) { Value = item.SourceId }); db.ExecuteNonQuery(cmdText, false); } trasaction.Commit(); } catch (Exception) { trasaction.Rollback(); return(false); } } return(true); }
public static SqliteParameter AddWithNullable(this SqliteParameterCollection parms, string parameterName, object nullable) { if (nullable != null) { return(parms.AddWithValue(parameterName, nullable)); } else { return(parms.AddWithValue(parameterName, DBNull.Value)); } }
public static SqliteParameter AddWithNullable <T>(this SqliteParameterCollection parms, string parameterName, T?nullable) where T : struct { if (nullable.HasValue) { return(parms.AddWithValue(parameterName, nullable.Value)); } else { return(parms.AddWithValue(parameterName, DBNull.Value)); } }
private SqliteParameterCollection DataSql_Parameters() { SqliteCommand SqliteCommand = new SqliteCommand(); SqliteParameterCollection ReturnParamter = SqliteCommand.Parameters; ReturnParamter.AddWithValue(LibraryWords.Row + 0.ToString(), txt); ReturnParamter.AddWithValue(LibraryWords.Row + 1.ToString(), txtport); return(ReturnParamter); }
private static void AppendParameters(SqliteParameterCollection collection, object[] parameters) { if (parameters == null || parameters.Length < 1) { return; } foreach (var parameter in parameters) { SqliteParameter sqliteParam = parameter as SqliteParameter; if (sqliteParam != null) { collection.Add(sqliteParam); continue; } // Perform Type guessing DbType dbType = DbType.String; switch (Convert.GetTypeCode(parameter)) { case TypeCode.Empty: case TypeCode.DBNull: collection.Add(new SqliteParameter(dbType, DBNull.Value)); continue; case TypeCode.Boolean: dbType = DbType.Boolean; break; case TypeCode.Byte: dbType = DbType.Byte; break; case TypeCode.SByte: dbType = DbType.SByte; break; case TypeCode.UInt16: dbType = DbType.UInt16; break; case TypeCode.Int16: dbType = DbType.Int16; break; case TypeCode.UInt32: dbType = DbType.UInt32; break; case TypeCode.Int32: dbType = DbType.Int32; break; case TypeCode.UInt64: dbType = DbType.UInt64; break; case TypeCode.Int64: dbType = DbType.Int64; break; case TypeCode.Single: dbType = DbType.Single; break; case TypeCode.Double: dbType = DbType.Double; break; case TypeCode.Decimal: dbType = DbType.Decimal; break; case TypeCode.DateTime: dbType = DbType.DateTime; break; } collection.Add(new SqliteParameter(dbType, parameter)); } }
public string GetCommandText_Delete(SqliteParameterCollection parameters) { var sbQuery = new StringBuilder(); sbQuery.AppendLine($"DELETE FROM {TableName}"); sbQuery.AppendLine($"WHERE {parameters[0].ParameterName} = @{parameters[0].ParameterName} "); for (int i = 1; i < parameters.Count; i++) { sbQuery.AppendFormat("AND {0} = @{0} ", parameters[i].ParameterName); } return(sbQuery.ToString()); }
public static SqliteParameterCollection AddWithValue( this SqliteParameterCollection parameters, string parameterName, SqliteType dbType, object value) { var parameter = new SqliteParameter(parameterName, dbType); parameter.Value = value; parameters.Add(parameter); parameter.ResetSqliteType(); return(parameters); }
//private void Save_image(queue Finsh_queue) { // var myByteArray = File.ReadAllBytes(Finsh_queue.Filename); // _DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(Finsh_queue.Filename + ".jpg", myByteArray, "Image")); //} //change private static SqliteParameterCollection DataSql_Parameters(string date, byte[] m, byte[] g, string j) { // var date = DateTime.Now.ToString(" HH:mm:ss"); SqliteCommand SqliteCommand = new SqliteCommand(); SqliteParameterCollection ReturnParamter = SqliteCommand.Parameters; ReturnParamter.AddWithValue(LibraryWords.Row + 0.ToString(), date); ReturnParamter.AddWithValue(LibraryWords.Row + 1.ToString(), m); ReturnParamter.AddWithValue(LibraryWords.Row + 2.ToString(), g); ReturnParamter.AddWithValue(LibraryWords.Row + 3.ToString(), j); return(ReturnParamter); }
public static SqliteParameterCollection AddSlidingExpirationInSeconds( this SqliteParameterCollection parameters, TimeSpan?value) { if (value.HasValue) { return(parameters.AddWithValue( Columns.Names.SlidingExpirationInSeconds, SqliteType.Integer, value.Value.TotalSeconds)); } else { return(parameters.AddWithValue(Columns.Names.SlidingExpirationInSeconds, SqliteType.Integer, DBNull.Value)); } }
void Parameterize(SqliteParameterCollection command, RuntimeDefinedParameterDictionary parameterDictionary) { if (null != parameterDictionary) { foreach (SqliteParameter parameter in command) { string name = parameter.ParameterName.TrimStart('@', '$'); if (!(parameterDictionary.ContainsKey(name) && parameterDictionary[name].IsSet)) { continue; } SpecifyParameter(command, parameter.ParameterName, parameterDictionary[name].Value); } } }
public static SqliteParameterCollection AddAbsoluteExpirationSQLite( this SqliteParameterCollection parameters, DateTimeOffset?utcTime) { if (utcTime.HasValue) { return(parameters.AddWithValue( Columns.Names.AbsoluteExpiration, SqliteType.Integer, utcTime.Value.ToUnixTimeMilliseconds())); } else { return(parameters.AddWithValue( Columns.Names.AbsoluteExpiration, SqliteType.Integer, DBNull.Value)); } }
void Parameterize(SqliteParameterCollection command, DataRow record) { if (null != record) { foreach (SqliteParameter parameter in command) { string name = parameter.ParameterName.TrimStart('@', '$'); if (!record.Table.Columns.Contains(name)) { continue; } SpecifyParameter(command, parameter.ParameterName, record[name]); } } }
void SpecifyParameter( SqliteParameterCollection parameters, string parameterName, object value ) { parameters[parameterName].ResetDbType(); parameters[parameterName].Value = value; var isSpecifiedName = parameterName + "IsSpecified"; if( parameters.Contains( isSpecifiedName )) { parameters[isSpecifiedName].Value = true; } }
void Parameterize( SqliteParameterCollection command, DataRow record ) { if (null != record) { foreach (SqliteParameter parameter in command) { string name = parameter.ParameterName.TrimStart('@', '$'); if (!record.Table.Columns.Contains(name)) { continue; } SpecifyParameter( command, parameter.ParameterName, record[name] ); } } }
void Parameterize(SqliteParameterCollection command, PSObject item) { if (null != item) { foreach (SqliteParameter parameter in command ) { string name = parameter.ParameterName.TrimStart('@', '$'); var prop = item.Properties.Match(name).FirstOrDefault(); if (null == prop) { continue; } SpecifyParameter(command, parameter.ParameterName, prop.Value); } } }
void Parameterize(SqliteParameterCollection command, RuntimeDefinedParameterDictionary parameterDictionary) { if (null != parameterDictionary) { foreach (SqliteParameter parameter in command) { string name = parameter.ParameterName.TrimStart('@', '$'); if (! (parameterDictionary.ContainsKey(name) && parameterDictionary[name].IsSet) ) { continue; } SpecifyParameter(command, parameter.ParameterName, parameterDictionary[name].Value); } } }
void Parameterize(SqliteParameterCollection command, object idValue) { if (null != idValue) { var pkf = PrimaryKeyField; if (!command.Contains(pkf)) { var p = new SqliteParameter("@" + pkf, idValue); command.Add(p); } else { command[PrimaryKeyField].ResetDbType(); command[PrimaryKeyField].Value = idValue; } } }