public class MediaPartner
{
[ PrimaryKey, AutoIncrement]
public int Id {get; set; }
public string PhoneNumber {get; set; }
public string CompanyName {get; set; }
public double Lat {get; set; }
public double Lng {get; set; }
public DateTime InsertedUtc {get; set; }
}
public class ImageGroup
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
public ListIdMediaPartner {get; set; }
public string ImagePath {get ; set; }
public bool IsSent {get; set; }
public DateTime InsertedUtc {get; set; }
}
Question:
public List< MediaPartner> IdMediaPartner {get; set; }
OR
public MediaPartner IdMediaPartner {get; set; }
does not compile.
My question is: Is there a way to establish a one-to-many relationship between these two tables?
Thank you!
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[MaxLength(8)]
public string Symbol {get; set; }
}
public class Valuation
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[Indexed]
public int StockId {get; set; }
public DateTime Time {get; set; }
public decimal Price {get; set ; }
}
sqlite-net has at least one extension, which allows you to declare the OneToMany attribute-see https://bitbucket.org/twincoders/sqlite-net-extensions, it can enable the following code :
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[ MaxLength(8)]
public string Symbol {get; set; }
[OneToMany] // One to many relationship with Valuation
public ListValuations {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; }
}
I’m not sure The exact implementation of this-for example, I don’t know if this uses real FOREIGN KEY constraints-but the code is open source, under active development, built-in mvvmcross plugin support, is cross-platform, and can be used for forks and contributions.
I have two simple tables as follows:
public class MediaPartner
{
[ PrimaryKey, AutoIncrement]
public int Id {get; set; }
public string PhoneNumber {get; set; }
public string CompanyName {get; set; }
public double Lat {get; set; }
public double Lng {get; set; }
public DateTime InsertedUtc {get; set; }
}
public class ImageGroup
{
[Pri maryKey, AutoIncrement]
public int Id {get; set; }
public ListIdMediaPartner {get; set; }
public string ImagePath {get; set; }
public bool IsSent {get; set; }
public DateTime InsertedUtc {get; set; }
}
Question:
public List< MediaPartner> IdMediaPartner {get; set; }
OR
public MediaPartner IdMediaPartner {get; set; }
does not compile.< /blockquote>
My question is: Is there a way to establish a one-to-many relationship between these two tables?
Thank you!
SQLite-net only uses indexes to provide cross-table references, such as:
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[MaxLength(8)]
public string Symbol {get; set; }
}
public class Valuation
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[Indexed ]
public int StockId {get; set; }
public DateTime Time {get; set; }
public decimal Price {get; set; }
}< p>sqlite-net has at least one extension, which allows the declaration of the OneToMany attribute-see https://bitbucket.org/twincoders/sqlite-net-extensions, it can enable the following code:
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
[MaxLength(8)]
public string Symbol {get; set; }
[OneToMany] // One to many relationship with Valuation
public ListValuations {get; set; }
}
public class Valuation
{
[P rimaryKey, 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; }
}I’m not sure about the exact implementation of this – for example, I don’t know if this uses real FOREIGN KEY constraints – but the code is open source, Under active development, the built-in mvvmcross plug-in support is cross-platform and can be used for forks and contributions.