Tag Archives: sql

Serialize a non-serializable custom object from a nuget package and store it in SQLite database

Questions: I’m working with some highly custom objects from a nuget package that I need to store in the local SQLite db using Xamarin. I tried using this code public static byte[] Serialize(ComplexType c) { byte[] arrayData; using(MemoryStream stream = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize( stream, c ); arrayData = stream.ToArray();… Read More »

Xamarin with PCLStorage – Where to place SQLite3 file?

Questions: I am reading ‘Xamarin in Action’ by Manning Publications and working on Countr example. I am using below code to retrieve Sqlite3 file as has been mentioned in chapter 7 of book. var local = FileSystem.Current.LocalStorage.Path; var datafile = PortablePath.Combine(local, “counters.db3”); connection = new SQLiteAsyncConnection(datafile); connection.GetConnection(); I wanted to add one more database which… Read More »

MySQL and C# Entity Framework “ProviderIncompatibleException”

Questions: i’m following the MySql tutorial to entity framework as listed here: https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html I have installed in my project via NuGet: – Entity Framework v6.2.0 – MySql.Data.Entity v6.10.7 And their corresponding dependencies. I have installed the MySql CONNECTOR/NET v8.0.11. I added the provider and connectionString to the App.config: <entityFramework codeConfigurationType=”MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6″> <defaultConnectionFactory type=”System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework” />… Read More »

Android Sqlite query for year and month

Questions: I have a record in the database with the date as 2017-08-26. Now I want to search the record with year and month only. I have implemented the query as @Query(“SELECT SUM(quantity) FROM DailyConsumption WHERE strftime(‘%y%m’, date) LIKE :date”) int getMonthlyQuantity(String date); And the part where i am calling this query is SimpleDateFormat dateFormat=… Read More »