1

的Windows手机应用程序,我试图挽救我的对象,我接到了我JSON回一个local storage分贝与SQLite使用SQLite本地存储

我已经导入了很多包,也SQLite的框架。

,我也做了这两个类: 活动

public class Activity : INotifyPropertyChanged 
    { 
     [SQLite.PrimaryKey, SQLite.AutoIncrement] 
     public int act_id 
     { 
      get; 
      set; 
     } 
     //The Id property is marked as the Primary Key 
     private int act_organization_id_value; 
     private int act_creator_id_value; 
     private int act_free_value; 
     private int act_subcription_value; 
     private int act_external_value; 
     private int act_active_value; 
     private int act_future_value; 
     private int act_status_value; 
     private int act_viewed_value; 
     private string act_location_value = String.Empty; 
     private string act_lng_value = String.Empty; 
     private string act_title_value = String.Empty; 
     private string act_information_value = String.Empty; 
     private string act_type_value = String.Empty; 
     private string act_color_value = String.Empty; 
     private string act_event_identifier_value = String.Empty; 
     private DateTime act_start_value = DateTime.Now; 
     private DateTime act_end_value = DateTime.Now; 

     [OneToMany(CascadeOperations = CascadeOperation.All)] 
     public List<ActivityMember> membrs { get; set; } 

     //Other getters and setters 
} 

活动成员

public class ActivityMember : INotifyPropertyChanged 
    { 
     [SQLite.PrimaryKey, SQLite.AutoIncrement] 
     public int mem_id 
     { 
      get; 
      set; 
     } 

     private int mem_activity_id_value; 
     private int mem_organization_id_value; 
     private int mem_role_id_value; 
     private int mem_creator_value; 
     private int mem_accepted_value; 
     private int mem_activity_accepted_value; 
     private int mem_active_value; 
     private int mem_deleted_value; 
     private string mem_profile_color_value = String.Empty; 
     private string mem_picture_value = String.Empty; 
     private string mem_email_value = String.Empty; 
     private string mem_phone_value = String.Empty; 
     private string mem_gsm_value = String.Empty; 
     private string mem_address_value = String.Empty; 
     private string mem_postal_value = String.Empty; 
     private string mem_city_value = String.Empty; 
     private string mem_country_id_value = String.Empty; 
     private string mem_first_name_value = String.Empty; 
     private string mem_last_name_value = String.Empty; 
     private string mem_extra_info_value = String.Empty; 
     private string mem_street_value = String.Empty; 
     private string mem_streetnumber_value = String.Empty; 
     private string mem_gender_value = String.Empty; 
     private DateTime mem_birthdate_value = DateTime.Now; 

     [ManyToOne]  // Many to one relationship with Activity 
     public Activity activity { get; set; } 

     // all other getters and setters 
} 

的activty可以有更多的ActivityMembers。 当我建立和运行,我得到以下错误: enter image description here

当我调试我发现它是由以下几行引起的: 在活动:

[OneToMany(CascadeOperations = CascadeOperation.All)] 
     public List<ActivityMember> membrs { get; set; } 

在activityMember:

[ManyToOne]  // Many to one relationship with Activity 
    public Activity activity { get; set; } 

如何正确地做到这一点的任何帮助?

编辑 我有这些引用:

enter image description here

+1

不知道这是否是相同的问题,但它看起来可能是:http://stackoverflow.com/questions/23463849/sqlite-extension-is-not-working-as-expected –

+0

@SebastianL是的,它在同一个平台上也是一样的错误,而且似乎是由同一个问题引起的。 – redent84

回答

0

错误是由SQLite.Net试图与List<ActivityMember>类型序列化财产造成,那它是SQLite.Net没有按类型不知道。通过使用SQLite-Net Extensions OneToMany属性注释它,它应该被SQLite.Net忽略,因为OneToMany继承自SQLite.Net Ignore属性。

如果该属性不被SQLite.Net忽略是因为Ignore属性未被识别。这个问题通常是由于您使用的SQLite.Net版本不同于SQLite-Net Extensions的版本而编译的。要解决这个问题,你必须确保所使用的SQLite.Net版本是相同的。

要解决它,您可以将SQLite-Net Extension sources复制到您的项目中,以强制该库与您的SQLite-Net版本链接。

响应EDIT

正如你可以在你的推荐人看到,你有两个SQLite.Net库:

  • SQLite.Net(和它的异步API SQLite.Net.Async)
  • SQLite,让Windows Phone的

您必须删除到SQLiteNetExtensions引用,SQLite.Net.AsyncSQLite.Net.Async,并针对您的SQLite For Windows Phone库编译SQLite-Net Extensions sources

+0

我可以获得这些来源吗?我只是将其粘贴到我的解决方案中?对不起,很新的Windows开发.. – Steaphann

+0

请参阅我的编辑我有ATM什么参考 – Steaphann

+0

@StefGeelen请参阅我的编辑进一步的细节 – redent84