0

What are various ways to have relationships (One-to-Many, Many-to-Many, etc) between database tables. I don't want to use SQLite-Net Extensions.

Does anyone know any sources for this. If you know one, kindly give a very simple example of doing it.

I've heard it can be done using LINQ's Join method. If you know how to use this, please provide a simple working example.

Anil
  • 193
  • 3
  • 14

1 Answers1

1

This is simple example For One-to-Many relationships using by LINQ

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

 var Query = (connection.Table<Valuation>().Where(
               c => c.StockId == StockItem.ID)).ToList();