本文整理汇总了C#中SQLiteConnection.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.Delete方法的具体用法?C# SQLiteConnection.Delete怎么用?C# SQLiteConnection.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public void Delete(int Number)
{
var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");
using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
{
var existingconact = conn.Query<Student>("select * from Students where Number =" + Number).FirstOrDefault();
if (existingconact != null)
{
conn.RunInTransaction(() =>
{
conn.Delete(existingconact);
});
}
}
}
示例2: DeleteGrade
public static void DeleteGrade(int id)
{
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
Student m = (from p in db.Table<Student>()
where p.Id == id
select p).FirstOrDefault();
if (m != null)
db.Delete(m);
}
}
示例3: DeleteStudentByEmail
/// <summary>
/// Delete a student by email
/// </summary>
/// <param name="email">Student Email</param>
public static void DeleteStudentByEmail(string email)
{
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
Student m = (from p in db.Table<Student>()
where p.Email == email
select p).FirstOrDefault();
if (m != null)
db.Delete(m);
}
}
示例4: DeleteStudents
/// <summary>
/// Delete all students in the database
/// </summary>
/// <param name="students"></param>
public static void DeleteStudents(IEnumerable<Student> students)
{
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
{
foreach (var item in students)
{
db.Delete(item);
}
}
}
示例5: DeleteItem
public string DeleteItem(int itemId)
{
string result = string.Empty;
using (var dbConn = new SQLiteConnection(App.SQLITE_PLATFORM, App.DB_PATH))
{
var existingItem = dbConn.Query<Media>("select * from Media where Id =" + itemId).FirstOrDefault();
if (existingItem != null)
{
dbConn.RunInTransaction(() =>
{
dbConn.Delete(existingItem);
if (dbConn.Delete(existingItem) > 0)
{
result = "Success";
}
else
{
result = "This item was not removed";
}
});
}
return result;
}
}
示例6: CreateDatabase
private async static Task<ObservableCollection<ItemsNews>> CreateDatabase(ObservableCollection<ItemsNews> itemsNews, string path)
{
ObservableCollection<ItemsNews> resultItems = new ObservableCollection<ItemsNews>();
if (!HttpRequest.HasInternet()) return await GetAllNews(path);
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), path))
{
var maxCountNews = 25;
var c = db.CreateTable<ItemsNews>();
var info = db.GetMapping(typeof(ItemsNews));
var items = (from p in db.Table<ItemsNews>()
select p).ToList();
var itemsCount = items.Count;
if (itemsCount == 0)
{
foreach (var item in itemsNews)
{
resultItems.Add(item);
}
}
if (itemsCount > maxCountNews && itemsCount != 0)
{
for (int i = itemsNews.Count-1; i > maxCountNews; i--)
{
var lasts = itemsNews[i];
itemsNews.Remove(lasts);
db.Delete(lasts);
}
}
db.InsertOrReplaceAll(itemsNews);
var resultColl = (from p in db.Table<ItemsNews>()
select p).ToList();
return new ObservableCollection<ItemsNews>(resultColl);
}
}