private static IEnumerable<KeyValuePair<string, object>> ToKeyValuePairs(Inventor inventor) { return new Dictionary<string, object> { {"身份证号", inventor.身份证号}, {"姓名", inventor.姓名}, {"电话", inventor.电话}, {"Email", inventor.Email} }; }
public void RemoveInventor(Inventor inventor) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); connection.Delete(InventorTableName, new KeyValuePair<string, object>("身份证号", inventor.身份证号)); } }
public void UpdateInventor(Inventor inventor) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); connection.Update(InventorTableName, new KeyValuePair<string, object>("身份证号", inventor.身份证号), ToKeyValuePairs(inventor)); } }
public void AddInventor(Inventor inventor) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); connection.Insert(InventorTableName, ToKeyValuePairs(inventor)); } }