This is a migrated thread and some comments may be shown as answers.

[Solved] My questions about Data Storage.

1 Answer 41 Views
Data Storage for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rajesh
Top achievements
Rank 1
Rajesh asked on 06 Jun 2014, 05:05 AM
Hi,

I have a lot of questions regarding the Data Storage Component that ships with XAML Suite for Windows 8. After reading the documentation I experimented with retrieval of data from a local storage database.

To start with.

I referenced the Telerik Data Storage for Windows 8.1 and Telerik UI for Windows 8.1
I copied an existing SQLite database to the application and copied it to the application run time folder.
And I used the following code to retrieve data from the database

var dbpath = new Telerik.Storage.Extensions.Context("demo.db", DatabaseLocation.Local);
var stringSQL = string.Format(@"select userid, firstname, lastname from users"); 
var p = dbpath.Get<Users>(stringSQL);
var k = p.Count;

this.SummaryGrid.ItemsSource = new List<Users>();

where Users is the class defined for the objects in the users table and SummaryGrid is a Telerik RADGrid control.

I am getting this error "Class 'Users' used as persistent class has more than one primary key columns. Each table may have at most one Primary Key." and then it is impossible to populate the grid. But I am getting the number of rows from the table.

My questions for Data Storage are

1. If I use a SQLite database and then use the Telerik Data Storage for Windows 8.1 are they compatible. Will it cause any problems.
2. When creating classes from tables in SQLite we use this [SQLite.PrimaryKey] for the column in the classes and it works when updating tables.
 What is the equivalent when using Telerik Data Storage. 
3. The primary reason I am trying out Telerik Data Storage is we can pass SQL Statements for updating whereas in SQLite we can pass only the object name.

And for your information, I was able to populate the Telerik RAD Grid from a SQLite database when using the sqlite-net libraries and the SQLite library for Windows 8.1.

Thanks,

Rajesh.

1 Answer, 1 is accepted

Sort by
0
Bulent
Telerik team
answered on 10 Jun 2014, 03:25 PM
Hello Rajesh,

Thank you for your interest regarding Telerik Data Storage for XAML.
As I understood, you use an existing SQLite database and try to access it via component's API.
This is so called database first approach which is not supported by Telerik Data Storage. This  corresponds to your first question. 
To specify a property as a primary key you should use [System.ComponentModel.DataAnnotations.Key] annotation on only one property, since complex primary keys are not supported by SQLite databases.
For more detailed information please refer to the component's documentation here.

Let me know if you need further assistance.

Regards,
Bulent
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Data Storage for XAML
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Bulent
Telerik team
Share this question
or