Members

 

ik multimedia arc 2 download


Name: ik multimedia arc 2 download
Category: Soft
Published: ilcamimas1977
Language: English

 


 


 

 

 

 

 

 

 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 

Windows 8 Storing Data With SQLite.
In a previous blog post, I showed the repository pattern with local or remote data storage. In this blog post, based in part on work done for my upcoming book Pro Windows 8 With C# and XAML by Jesse Liberty and Jon Galloway , we’re going to explore storing data using Sqlite.
To use SQLite you will need to add the SQLite Visual Studio Extension. To do so, open VS and go to Tools->Extensions and Updates. Click on Online and in the search type SQLite for windows runtime. When it comes up click download, it will install the extension.
Restart Visual Studio and create a new application using the Blank template.
When Visual Studio is ready, we’ll add the references. Right click on References and choose Add Reference . Under Windows Extensions, click SQLite for Windows Runtime and click OK.
Next we need to add the Nuget Package for SQLite .NET. Go to Tools->Library Package Manager->Manage NuGet packages. Search online for Sqlite-net. Click install and install that package.
Notice that you may have alerts on your references that “Any CPU is not supported…” You must support a specific CPU. Go to Build->Configuration Manager. Choose the CPU you want to support. Rebuild.
Add a DataModel folder to your project. Add a new Customer class to the DataModel folder. This class is the same as in the previous example, except that we attribute the Id property with PrimaryKey, AutoIncrement,
Add the IDataRepository interface to the DataModel folder (this is identical to the previous example),
Implement the IDataRepository interface with the concrete class SqliteRepository,
Add two data members. The first, _dbPath will point to a file in the LocalFolder, the second will be an ObservableCollection ,
The constructor calls the initialize method,
The initialize method checks to see if we have any records. If not, it seeds the database with two hard-coded records, otherwise it calls Load.
The Load method creates a new observable collection, creates an async connection to our path and then calls QueryAsync passing in the search string, thus populating the ObservableCollection which it returns,
The Add method calls Customers.Add passing in a customer, gets the connection to the database, and returns the result of calling InsertAsync, passing in the new customer,
Remove is the inverse of Add, it removes a given customer record from the customers table.
Finally, Update works much as it did in the previous example, we first get our old version of the customer (using the lambda expression) and we remove the old and replace it with the new version.
That completes our repository, we can now turn to the view model, which we’ll also place in the DataModel folder for this example. The ViewModel is unchanged from the previous demo.
Additionally, our view is unchanged from the previous demo. (Don’t forget to uncomment the styles!)
In the code behind, the first thing we do is create two member varialbes. The first is an instance of IDataRepository that instantiates our SqliteRepository. The second is to declare a member variable of type ViewModel,
In the constructor, as we did last time, we’ll create the view Model, initialize it and then set it as the DataContext,
The save and delete event handlers are identical to the previous example,
That’s it, we can now build and run the application. When it first comes up you’ll see that the database was seeded with two values,
We can easily add a new value, then swipe up from the bottom to bring up the save button. As soon as the button is clicked, the new value is saved and shown in our list box .

http://nexpsmetrozpcons.eklablog.com/r-b-instrumentals-free-downloa...

Views: 1

Comments are closed for this blog post

© 2024   Created by PH the vintage.   Powered by

Badges  |  Report an Issue  |  Terms of Service