Start a new topic

Parsing a list of string gives "Don't know about System.Collections.Generic.List`1[System.String]" in C#

I have a data model in Kinvey store named "debug" that looks like below, 

  

{
  "id": 1719844608,
  "firstName": "Johnnie",
  "lastName": "Jonathan",
  "phones": {
    "home": "524-789-3468",
    "mobile": "691-772-7392"
  },
  "email": [
    "krtxlhamd@itc.com",
    "ljyaaojkr@itc.org"
  ],
  "dateOfBirth": "1999-05-19T00:00:00.000Z",
  "registered": true,
  "gender": "female",
  "photo": 41
}

Here, I have an array of string under key email.

When I try to get the model using FindAsync(); I get the following exception,  


System.NotSupportedException
Don't know about System.Collections.Generic.List`1[System.String]

 Here is my corresponding C# model class 


  

using System;
using System.Net;
using System.Collections.Generic;
using Kinvey;
using Newtonsoft.Json;
using SQLite.Net;
using SQLite.Net.Attributes;

namespace ABC
{
    [JsonObject(MemberSerialization.OptIn)]
    public partial class DebugModel : Entity
    {
        [JsonProperty("gender")] public string Gender { get; set; }
        [JsonProperty("email")] public List<string> Email { get; set; }
        [JsonProperty("dateOfBirth")] public string DateOfBirth { get; set; }
        [JsonProperty("firstName")] public string FirstName { get; set; }
        [JsonProperty("lastName")] public string LastName { get; set; }
        [JsonProperty("photo")] public long Photo { get; set; }
        [JsonProperty("phones")] public Phones Phones { get; set; }
        [JsonProperty("registered")] public bool Registered { get; set; }

        public DebugModel() {}
    }

    [JsonObject]
    public partial class Phones: ISerializable<string>
    {
        [JsonProperty("home")] public string Home { get; set; }
        [JsonProperty("mobile")] public string Mobile { get; set; }

        public Phones() { }

        public string Serialize()
        {
            return JsonConvert.SerializeObject(this);
        }
    }
}

 This is how I am getting the data from Kinvey store, 


 

private async void GetData()
{
    DataStore<DebugModel> dataStore = DataStore<DebugModel>.Collection("debug");
    List<DebugModel> debugs = new List<DebugModel>();
    debugs = await dataStore.FindAsync();
    foreach (DebugModel d in debugs)
    {
        Debug.WriteLine("Tag: " + d);
    }
}

 Please reply how to resolve this issue? Any help is appreciated. 

Thanks in advance! 


1 person has this question

Hi,

I am looking into this. Could you please answer following questions


  • Which version of the Xamarin sdk are you using?
  • On which line of code are you getting this exception? or is it in the response of FindAsync()?
  • Could you please try this with keeping only 'email' in the DebugModel class? That way we can verify if it is what is causing the problem.


Please get back to us with the answers.


Regards,
Abhijeet


Hello Abhijeet, 


Thanks for your reply. Here are the answers, 


1. Using Xamarin.Forms (2.4.0.280), Kinvey (3.0.17)

2. Getting the exception in this line, 

 

DataStore<DebugModel> dataStore = DataStore<DebugModel>.Collection("debug");

Here is the full stacktrace, 

 

System.NotSupportedException: Don't know about System.Collections.Generic.List`1[System.String]
  at SQLite.Net.Orm.SqlType (SQLite.Net.TableMapping+Column p, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary`2[TKey,TValue] extraTypeMappings) [0x002e4] in <8f2bb39aeff94a30a8628064be9c7efe>:0
  at SQLite.Net.Orm.SqlDecl (SQLite.Net.TableMapping+Column p, System.Boolean storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer, System.Collections.Generic.IDictionary`2[TKey,TValue] extraTypeMappings) [0x00016] in <8f2bb39aeff94a30a8628064be9c7efe>:0
  at SQLite.Net.SQLiteConnection.<CreateTable>b__66_0 (SQLite.Net.TableMapping+Column p) [0x00013] in <8f2bb39aeff94a30a8628064be9c7efe>:0
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/external/corefx/src/System.Linq/src/System/Linq/Select.cs:251
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:19
  at SQLite.Net.SQLiteConnection.CreateTable (System.Type ty, SQLite.Net.Interop.CreateFlags createFlags) [0x0004c] in <8f2bb39aeff94a30a8628064be9c7efe>:0
  at SQLite.Net.SQLiteConnection.CreateTable[T] (SQLite.Net.Interop.CreateFlags createFlags) [0x00000] in <8f2bb39aeff94a30a8628064be9c7efe>:0
  at Kinvey.SQLiteCache`1[T].createTable () [0x00000] in <fe5ad8ee3e1044829806fc93302a4933>:0
  at Kinvey.SQLiteCache`1[T]..ctor (System.String collection, SQLite.Net.Async.SQLiteAsyncConnection connectionAsync, SQLite.Net.SQLiteConnection connectionSync, SQLite.Net.Interop.ISQLitePlatform platform) [0x0001c] in <fe5ad8ee3e1044829806fc93302a4933>:0
  at Kinvey.SQLiteCacheManager.GetCache[T] (System.String collectionName) [0x00083] in <fe5ad8ee3e1044829806fc93302a4933>:0
  at Kinvey.DataStore`1[T]..ctor (Kinvey.DataStoreType type, System.String collectionName, Kinvey.AbstractClient client) [0x00069] in <fe5ad8ee3e1044829806fc93302a4933>:0
  at Kinvey.DataStore`1[T].Collection (System.String collectionName, Kinvey.AbstractClient client) [0x00000] in <fe5ad8ee3e1044829806fc93302a4933>:0
  at Vromon.Views.HomePage+<GetData>d__4.MoveNext () [0x00018] in /Users/shahab/Documents/Work/Playground/vromon/Vromon/Views/HomePage.xaml.cs:73
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/Foundation/NSAction.cs:163
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at Vromon.iOS.Application.Main (System.String[] args) [0x00001] in /Users/shahab/Documents/Work/Playground/vromon/iOS/Main.cs:17

 


However, if I comment out the line, 

 

// [JsonProperty("email")] public List<string> Email { get; set; }

all works perfectly.

 

3. Removed all other properties but Email, got the same exception.  

Hi Shahab,

It will really help us if you could please share your project with us. If you are not comfortable with sharing it here you can email it to me(abhijeet@kinvey.com). I will continue looking into this.

Regards,
Abhijeet  

Hello Abhijeet, 


I have sent you an email with the project attached. Please let me know if you need any details. 


Thank you. 

Hello Abhijeet, 


I think you have missed the email. I am uploading the project here. Please take a look. 


Thank you. 

zip
(68.7 KB)

Hi ..Was this issue resolved. If yes how to fix it. I am facing this issue since i have upgraded kinvey nuget to latest version in my project at the very same place (datastore.collection). Previously it was working fine.


This is the exception thrown every time 

System.NotSupportedException: Don't know about CoreReturns.Models.CoreDestination

  at

SQLite.Orm.SqlType (SQLite.TableMapping+Column p, System.Boolean storeDateTimeAsTicks) [0x0022f] in <30089851bee54b1fb949cdceb3d4ac78>:0 

at SQLite.Orm.SqlDecl (SQLite.TableMapping+Column p, System.Boolean storeDateTimeAsTicks) [0x00016] in <30089851bee54b1fb949cdceb3d4ac78>:0 

at SQLite.SQLiteConnection.<CreateTable>b__55_0 (SQLite.TableMapping+Column p) [0x00007] in <30089851bee54b1fb949cdceb3d4ac78>:0 

 at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <715c2ff6913942e6aa8535593b3ef35a>:0 

at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <715c2ff6913942e6aa8535593b3ef35a>:0 

at SQLite.SQLiteConnection.CreateTable (System.Type ty, SQLite.CreateFlags createFlags) [0x000e0] in <30089851bee54b1fb949cdceb3d4ac78>:0 

 at SQLite.SQLiteConnection.CreateTable[T] (SQLite.CreateFlags createFlags) [0x00000] in <30089851bee54b1fb949cdceb3d4ac78>:0 

at Kinvey.SQLiteCache`1[T].createTable () [0x00000] in /Users/admin/dotnet-sdk/Kinvey.Core/Offline/SQLiteCache.cs:63 

at Kinvey.SQLiteCache`1[T]..ctor (System.String collection, SQLite.SQLiteAsyncConnection connectionAsync, SQLite.SQLiteConnection connectionSync) [0x00014] in /Users/admin/dotnet-sdk/Kinvey.Core/Offline/SQLiteCache.cs:56 

at Kinvey.SQLiteCacheManager.GetCache[T] (System.String collectionName) [0x0007f] in /Users/admin/dotnet-sdk/Kinvey.Core/Offline/SQLiteCacheManager.cs:196 

at Kinvey.DataStore`1[T]..ctor (Kinvey.DataStoreType type, System.String collectionName, Kinvey.AbstractClient client) [0x0005d] in /Users/admin/dotnet-sdk/Kinvey.Core/Store/DataStore.cs:134 

at Kinvey.DataStore`1[T].Collection (System.String collectionName, Kinvey.DataStoreType type, Kinvey.AbstractClient client) [0x00000] in /Users/admin/dotnet-sdk/Kinvey.Core/Store/DataStore.cs:166 

at CoreReturns.KinveyService.GetDataStore[T] (System.String collection) [0x00001] in D:\PS-CoreReturnsDriverApp\CoreReturns\CoreReturns\Service\KinveyService.cs:161 

  at CoreReturns.KinveyService.IsDataPendingToSaveRemote[T] (System.String collection) [0x00001] in D:\PS-CoreReturnsDriverApp\CoreReturns\CoreReturns\Service\KinveyService.cs:176 

  at CoreReturns.App+<TryToUploadDataAndUpdateAsync>d__22.MoveNext () [0x0004a] in D:\PS-CoreReturnsDriverApp\CoreReturns\CoreReturns\CoreReturns.xaml.cs:136 }

No, it's not resolved. Eventually I had to drop Kinvey and moved to another platform. Thanks. 

Login or Signup to post a comment