SQlite.Net.SQliteCommand ExecuteQuery requires class - windows

I am working on SQlite with Windows Universal App. I have a scenario where the column names are unknown and want to fetch the data from Sqlite table. The method ExecuteQuery in SQlite.Net.SQlite.SQlCommand expects a class name to be passed. I tried with dictionary but no luck it comes as a empty. Anything related this would be helpful. I cant find much document online.
SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath);
SQLiteCommand cmd = conn.CreateCommand(query);
List<Dictionary<string, string>> datalist =cmd.ExecuteQuery<Dictionary<string, string>>();

What you need is actually map it to a list of dynamic objects with SQLite in UWP app, I'm sorry to tell you that SQLite for UWP doesn't support this function.
And Dapper.Net is now not available for UWP apps.
You can try to use web API/service to solve your problem, for example you can submit your data to the web API, web API uses dapper to get data from your database and pass it back to your app.

Related

ValidateAntiForgeryToken breaks read on .NET Core with IdentityServer4

I am doing a basic read and write functionality to a IdentityServer4 application using .NET Core 2.0 and have come across an issue. When trying to load clients the ValidateAntiForgeryToken attribute seem to break my update.
I know that EF core does not support lazy loading so we are using an Unit Of Work pattern. I would create separate repositories for Client, ClientScopes, Secrets, etc. and grab the data for each. I will pass in a Func<> to allow filtering when grabbing ClientScopes etc. So a method call would look like this
ClientScopeResitory.GetAll(a => a.Client.Id == id)
which would then access the dbset like this
public IEnumerable GetAll(Func<T, object> predicate == null)
{
return predicate != null ? dbset.Where(predicate) : dbset
}
My issue is when loading the client in my read operation this works just fine. However when using the same code in my update where the ValidateAntiForgeryToken is present it breaks. What happens is in the creation of the repository during the read, the Clients are loaded in with the dbset. However, in the update, the clients are not. When the ValidateAntiForgery attribute is removed. The clients are loaded again and the update works fine. Anyone have any ideas what is going on. I can supply full code upon request. Thanks in advance.
Also, I apologies for any bad grammar or spelling, I wrote this in a hurry

IndexedDB view all Databases and Object Stores

I'm using IndexedDB in a Windows 8 app and I'm very new to both. I've been able to successfully create, read, update, delete objects from object stores, and have created a couple databases and a few object stores. My question is how can I list all of my object stores and databases? I create a few bogus ones that are not needed and I would like to clean things up a bit, but I can't remember what they are named. Maybe this is anal retentive, but it seems like it should be possible to list all databases and stores. Thanks!
At the time of writing this post [chrome 72], You can list all the databases using following command in console of the browser. Essentially indexedDB.databases() is a Promise. You can use it to get list of all databases as an array. Run a loop on the array to get the names of databases.
indexedDB.databases().then(r => console.log(r))
Hope this helps
EDIT 2018 This answer is no longer applicable:
webkitGetDatabaseNames() is deprecated in chrome 60
In Chrome webkit there was a function which would return all database names, this function is no longer available as of Chrome 60 (webkitgetdatabasenames):
indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args)
{ console.log(sender.target.result); };
And there is another function which list all object stores in a single database which work in all browsers:
indexedDB.open(databaseName).onsuccess = function(sender, args)
{ console.log(sender.target.result.objectStoreNames); };
There is currently no way of enumerating the existing databases in the standard. Windows 8 apps use IE, which does not provide the non-standard webkitGetDatabaseNames method. You might be able to clear the databases using the options dialog in IE10.
Listing the stores inside a database is defined in the standard using the objectStoreNames method of an IDBDatabase instance.
Since all other topics reference back here as a duplicates. In Chrome you can view and delete all created databases in Developer Tools > Application > Storage.
To view IndexedDB internals: chrome://indexeddb-internals/

Web Api and Odata without Entity Framework

I am having trouble getting OData to work with Asp.Net Web Api when the underlying data is NOT coming from Entity Framework.
I am using the latest OData Nuget package (Microsoft ASP.NET Web API OData 0.2.0-alpha release) but when I attempt to pass an OData query (say $top=10) I receive the error:
The given key was not present in the dictionary
If I don't send an OData query I can call the method just fine. The other methods in the same Web Api project that use Entity Framework work fine with OData queries. The one's that don't work are using Subsonic ORM to query an underlying AS400 data source. It returns an IQueryable. This worked just fine before the VS 2012 and .NET 4.5 RTM was released and OData was moved into a separate package. (i.e. worked with beta and RC versions of VS2012 and .NET 4.5)
Any ideas would be appreciated.
I guess this issue is caused by stable ordering, which doesn't work well with the underlying query provider. Could you put the call stack of the error to confirm it?
One big change with OData query composition in this release is that it ensures stable ordering before taking top items. The reason to do that is user may have random data source which makes return data keep changing.
The way web api odata package does is to add OrderyBy [Keys] query before executing top. Or if there is no key defined in the model (Keys are ID, EntityID, or [Key] attributed property), it will use all the primitive properties in the model to order.
If you can make sure that the data source will always return data with stable ordering, you can turn off this feature by code:
[Queryable(EnsureStableOrdering = false)]

modyfing a sqlite db mapped via core data throws errors: uncaught exception of class 'NSCFString'

I have an iphone app that has a sqlite db, mapped to core data. All the data manipulation in the app is via Coredata.
On one table I wanted to add a string attribute. And I did two things both with similar crashes:
I tried to use Mesasql to alter the structure. I easily added a Varchar column. But it crashes.
On a separate attempt, with the mapped SQLlite db, restored, I tried adding a attribute to the entity in core data and it crashed.
This is the error I got:
* Terminating app due to uncaught exception of class 'NSCFString'
terminate called after throwing an instance of 'NSCFString'
So, how can I alter the structure of the sqlite table mapped to core data without breaking the app? Am I fogetting to do a commit or something like that?
Please help
Every time you modify an entity you have to delete the sqlite store. If your application has already shipped, the alternative is to migrate your data. This SO answer offers a simple explanation of how to do that.

wp7 odata v2 dataservicestate save and restore methods tombstoning example needed

I am looking for an example of how to use the new DataServiceState Save and Restore methods in a WP7 application in order to tombstone a datacontext - I cannot find any examples and the approach I used resulted in an exception
this saves the data context correctly
PhoneApplicationService.Current.State["DataContext"] = DataServiceState.Save(this.Model.Entities);
this attempts to restore it after the app is re-activated
var dc = (PhoneApplicationService.Current.State["DataContext"] as DataServiceState).Restore();
but throws an exception
An item could not be added to the collection. When items in a DataServiceCollection are tracked by the DataServiceContext, new items cannot be added before items have been loaded into the collection.
This is the same exception I get if I try to reload a datacontext that I stored "directly" (without using the DataServiceState.Save method) in the PhoneApplicationService.Current.State. I cannot find any offical documentation on the new ODATA v2 DataServiceState class or examples.
thanks
Michael
I am looking for an example of how to use the new DataServiceState Save and Restore methods in a WP7 application in order to tombstone a datacontext
Are you sure? First link - bottom of the page.
Have you tried the walkthrough here?
How to: Preserve and Restore Application State for Windows Phone
Storing and retrieving datacontext is tricky due to serialization and object reference issues. The MSFT team is working on improving DataServiceState. I've succeeded in saving and restoring the context in a WP7 app, by storing the DataServiceState returned by Save() in the app state (just like you've done). Then on activated, I first instantiate my DataServiceClient (which contains the context and the DataServiceCollection), and then I call a RestoreData method in the client and pass the retrieved DataServiceState to it. The method restores the context and DSC within the DataServiceClient.

Resources