MVVMCROSS community SQLITE – Table relationship

I have two simple forms 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
{
[PrimaryKey, AutoIncrement]
public int Id {get; set; }
public List IdMediaPartner {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!

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 ; }
}

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 List 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; }
}

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 List IdMediaPartner {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 List Valuations {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.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 869 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.