本文整理汇总了C#中SQLite.SQLiteConnection.DeleteAll方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.DeleteAll方法的具体用法?C# SQLite.SQLiteConnection.DeleteAll怎么用?C# SQLite.SQLiteConnection.DeleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLite.SQLiteConnection.DeleteAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnDeleteAll_Click
private void btnDeleteAll_Click(object sender, RoutedEventArgs e)
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.DeleteAll<User>();
db.DeleteAll<AddressBookEntree>();
}
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(Dashboard));
}
示例2: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Get a reference to the SQLite database
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "budget.sqlite");
// Initialize the database if necessary
using (var db = new SQLite.SQLiteConnection(this.DBPath))
{
// Create the tables if they don't exist
db.CreateTable<Budget>();
db.CreateTable<BudgetEnvelope>();
db.CreateTable<Account>();
db.CreateTable<Transaction>();
db.DeleteAll<Budget>();
db.Insert(new Budget()
{
Id = 1,
PaycheckAmount = 1000.0f,
Frequency = PaycheckFrequency.SemiMonthly,
Name = "My New Budget"
});
Budget b = db.Table<Budget>().First();
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}
示例3: ResetDBData
public static void ResetDBData()
{
var app = (Application.Current as App);
using (var db = new SQLite.SQLiteConnection(app.DBPath))
{
db.DeleteAll<JournalEntry>();
//db.Insert(new JournalEntry()
//{
// Id = 1,
// Title = "Journal Entry 1",
// Content = "A journal entry content string blah blah",
// date = DateTime.Now
//});
//db.Insert(new JournalEntry()
//{
// Id = 2,
// Title = "Journal Entry 2",
// Content = "A journal entry content string 2 blah blah",
// date = DateTime.UtcNow
//});
}
}
示例4: ResetData
private void ResetData()
{
GenericListToByteArray converter = new GenericListToByteArray();
GenericDictionaryToByteArray dictionaryConverter = new GenericDictionaryToByteArray();
using (var db = new SQLite.SQLiteConnection(DBPath))
{
// Empty the Customer and Project tables
//db.DeleteAll<Meal>();
db.DeleteAll<MealItem>();
var newMealItem = new MealItem()
{
Name = "Schweinerückenbraten in Rahmsauce",
Category = "Pork",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { {1,15}, {2,20}, {3,30}, {4, 40} })
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "Rinderrouladen in herzhafter Sauce",
Category = "Beef",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "kleine Röstkartoffeln(mit geschmorten Speck und Zwiebeln)",
Category = "SideDish",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "Rahmkohlrabi",
Category = "Vegetables",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "Blumenkohl (mit Sauce Hollandaise)",
Category = "Vegetables",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "Rote Grütze mit Vanillesauce",
Category = "Desserts",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
newMealItem = null;
newMealItem = new MealItem()
{
Name = "Herrencreme",
Category = "Desserts",
IngredientIDsWithTotalAmount = (byte[])dictionaryConverter.Convert(new Dictionary<int, int>() { { 1, 15 }, { 2, 20 }, { 3, 30 }, { 4, 40 } }, null, null, "")
};
db.Insert(newMealItem);
// Add seed customers and projects
/*
var newMeal = new Meal()
{
Name = "Jutta Althues",
DeliveryDate = DateTime.Now,
NumberOfGuests = 120,
MealItemIDs = (byte[])converter.Convert(new List<int>() {1,2,3,4,5,6,7,8}, null, null, ""),
Contact = "Contact1"
};
db.Insert(newMeal);
newMeal = null;
newMeal = new Meal()
{
Name = "Heinz Benter",
DeliveryDate = DateTime.Now,
NumberOfGuests = 83,
MealItemIDs = (byte[])converter.Convert(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }, null, null, ""),
Contact = "Contact2"
};
db.Insert(newMeal);
newMeal = null;
newMeal = new Meal()
{
Name = "MGV",
//.........这里部分代码省略.........
示例5: PerformSuspenedAction
private static void PerformSuspenedAction(string pathToDatabase)
{
using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
db.DeleteAll<Item> ();
db.DeleteAll<Trader> ();
db.DeleteAll<AdUser> ();
}
}
示例6: ConnectBridgeClicked
async void ConnectBridgeClicked (object sender, EventArgs e)
{
IBridgeLocator locator = new HttpBridgeLocator ();
IEnumerable<string> bridgeIPs = await locator.LocateBridgesAsync (TimeSpan.FromSeconds (5));
IpAddress = bridgeIPs.FirstOrDefault ();
client = new LocalHueClient (IpAddress);
var appKey = new HueAppKey{ AppId = await client.RegisterAsync ("pooberry", "iphone") };
var bridgeIp = new HueBridge { HueBridgeIpAddress = IpAddress };
var conn = new SQLite.SQLiteConnection (_pathToDatabase);
//set up bridge table
conn.CreateTable<HueBridge> ();
conn.DeleteAll<HueBridge> ();
//set up app key table
conn.CreateTable<HueAppKey> ();
conn.DeleteAll<HueAppKey> ();
//insert app key and bridge ip into database
var db = new SQLite.SQLiteConnection (_pathToDatabase);
db.Insert (bridgeIp);
db.Insert (appKey);
var alert = new UIAlertView ("Success!", "Feel free to play with your lights!", null, "OK");
alert.Show ();
}
示例7: LoadData
private void LoadData()
{
using (var db = new SQLite.SQLiteConnection(DBPath))
{
// Empty the Customer table
db.DeleteAll<Customer>();
// Add seed customers
var newCustomer = new Customer()
{
Name = "Adventure Works",
City = "Bellevue",
Contact = "Mu Han"
};
db.Insert(newCustomer);
newCustomer = new Customer()
{
Name = "Contoso",
City = "Seattle",
Contact = "David Hamilton"
};
db.Insert(newCustomer);
newCustomer = new Customer()
{
Name = "Fabrikam",
City = "Redmond",
Contact = "Guido Pica"
};
db.Insert(newCustomer);
newCustomer = new Customer()
{
Name = "Tailspin Toys",
City = "Kent",
Contact = "Michelle Alexander"
};
db.Insert(newCustomer);
}
}