[英]Windows phone app with sqlite local storage
我正在嘗試使用SQLite
將從JSON
對象保存到local storage
數據庫中
我已經導入了很多軟件包以及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
}
一個活動可以有更多的ActivityMembers。 構建並運行時,出現以下錯誤:
在調試時,我發現它是由以下幾行引起的:在活動中:
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<ActivityMember> membrs { get; set; }
活動中的成員:
[ManyToOne] // Many to one relationship with Activity
public Activity activity { get; set; }
任何有關如何正確執行此操作的幫助?
編輯我有這些參考:
該錯誤是由SQLite.Net嘗試使用List<ActivityMember>
類型序列化屬性引起的,該屬性是SQLite.Net不知道的類型。 通過使用SQLite-Net擴展OneToMany
屬性進行注釋,SQLite.Net應該忽略它,因為OneToMany
繼承自SQLite.Net Ignore
屬性。
如果該屬性未被SQLite.Net忽略,則是因為無法識別“ Ignore
屬性。 通常是由於您使用的SQLite.Net版本與針對SQLite-Net Extensions的版本不同而引起的。 要解決此問題,必須確保使用的SQLite.Net版本相同。
為了解決這個問題,您可以將SQLite-Net擴展源復制到項目中,以強制庫鏈接到您的SQLite-Net版本。
回應編輯 :
如您在參考文獻中所見,您有兩個SQLite.Net庫:
您必須刪除對SQLiteNetExtensions
, SQLite.Net.Async
和SQLite.Net.Async
的引用,並SQLite For Windows Phone
的SQLite For Windows Phone
庫編譯SQLite-Net Extensions
源 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.