本文整理汇总了C#中SQLiteConnection.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.Update方法的具体用法?C# SQLiteConnection.Update怎么用?C# SQLiteConnection.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.Update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveOptions
public static int SaveOptions(Options options)
{
using (SQLiteConnection conn = new SQLiteConnection(dbLocation))
{
return conn.Update(options);
}
}
示例2: UpdateJobStatus
public JobDto UpdateJobStatus(int jobId, string status)
{
using (var databaseConnection = new SQLiteConnection(new SQLitePlatformWP8(), this.DatabaseFilePath))
{
var job = databaseConnection.Table<Job>().FirstOrDefault(j => j.Id == jobId);
if (job == null)
{
throw new Exception("Unable to find Job in database!");
}
job.JobStatus = status;
databaseConnection.Update(job);
return Mapper.Map<JobDto>(job);
}
}
示例3: Update
public void Update(Student student)
{
var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");
using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
{
var existingStudent = conn.Query<Student>("select * from Students where Number =" + student.Number).FirstOrDefault();
if (existingStudent != null)
{
existingStudent.Name = student.Name;
existingStudent.Number = student.Number;
existingStudent.Department = student.Department;
conn.RunInTransaction(() =>
{
conn.Update(existingStudent);
});
}
}
}
示例4: AddOrUpdateGradeToStudent
public static void AddOrUpdateGradeToStudent(Grade grade)
{
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
if (grade.Id == 0)
{
// New
db.Insert(grade);
}
else
{
// Update
db.Update(grade);
}
}
}
示例5: AddOrUpdateStudent
/// <summary>
/// With a Student Id == 0, will create a new student
/// </summary>
/// <param name="student"></param>
public static void AddOrUpdateStudent(Student student)
{
// Create a new connection
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
if (student.Id == 0)
{
// New
db.Insert(student);
}
else
{
// Update
db.Update(student);
}
}
}
示例6: SavePerson
public static void SavePerson(Person person)
{
// Create a new connection
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
// Activate Tracing
db.TraceListener = new DebugTraceListener();
if (person.Id == 0)
{
// New
db.Insert(person);
}
else
{
// Update
db.Update(person);
}
}
}
示例7: SaveItem
public string SaveItem(MediaViewModel item)
{
string result = string.Empty;
using (var db = new SQLiteConnection(App.SQLITE_PLATFORM, App.DB_PATH))
{
try
{
var existingItem = (db.Table<Media>().Where(
c => c.Id == item.Id)).SingleOrDefault();
if (existingItem != null)
{
existingItem.Id = item.Id;
existingItem.Name = item.Name;
existingItem.VidOrPic = item.VidOrPic;
int success = db.Update(existingItem);
}
else
{
int success = db.Insert(new Media()
{
Id = item.Id,
Name = item.Name,
CreationDate = item.CreationDate,
VidOrPic = item.VidOrPic
});
}
result = "Success";
}
catch
{
result = "This item was not saved.";
}
}
return result;
}