![](/img/trans.png)
[英]Using SQLite-Net Extensions and SQLiteConnection in Xamarin.Mac
[英]Using SQLite-Net Extensions and OneToMany relation
我在嘗試為Windows Phone 8.1實現具有OneToMany關系的SQLite-Extensions示例時遇到了困難。 我真的很想使用這個功能,但是我正在試着讓它發揮作用。 就像在這個問題中一樣,當我嘗試將提供的示例用於具有Valuations列表的Stocks表時:
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[MaxLength(8)]
public string Symbol { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)] // One to many relationship with Valuation
public List<Valuation> Valuations { get; set; }
}
public class Valuation
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[ForeignKey(typeof(Stock))] // Specify the foreign key
public int StockId { get; set; }
public DateTime Time { get; set; }
public decimal Price { get; set; }
[ManyToOne] // Many to one relationship with Stock
public Stock Stock { get; set; }
}
我嘗試創建表我得到錯誤:
app_name.exe中發生類型為“System.NotSupportedException”的異常但未在用戶代碼中處理附加信息:不知道> System.Collections.Generic.List`1 [app_name.Model.modelName]
我最初包含了對sqlite-net以及SQLiteNetExtensions-PCL的NuGet包引用,但之前提到過這是由於引用了錯誤版本的sqlite-net。
但是我已經嘗試下載sqlite-net的源代碼並在本地構建它並且它不會被SQLiteNetExtensions直接引用。
我已經在我的解決方案中本地包含了源代碼,它似乎沒有什么區別。 有人會有進一步的建議嗎? 我沒有遇到任何可下載的示例。
如果您已添加對SQLiteNetExtensions-PCL的引用,則不需要從VS / Add References手動添加對SQLite的引用,因為Nuget包中包含正確的版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.