Help needed with SQLite.Net Extension

ValOkaforValOkafor USMember, University ✭✭

I can use some help with using SQLite.Net, I must be doing something wrong with the Async methods. I have an Invoice entity with the following property

    public class Invoice : IEntityBase
    {

        [PrimaryKey, AutoIncrement, Column("_id")]
        public int Id { get; set; }
        public decimal TaxAmount { get; set; }
        public decimal AmountPaid { get; set; }
        public decimal BalanceDue { get; set; }
        public string Notes { get; set; }

        [ForeignKey(typeof(Client))]
        public int ClientId { get; set; }

        [OneToOne]
        public Client Client { get; set; }

        [OneToMany(CascadeOperations = CascadeOperation.All)] 
        public List<LineItem> LineItems { get; set; }

    }

And the referenced Client and LineItem entity as follows

   public class Client : IEntityBase
    {
        [PrimaryKey, AutoIncrement, Column("_id")]
        public int Id { get; set; }
        public string ClientName { get; set; }
        public string ClientEmail { get; set; }

        [ForeignKey(typeof(Invoice))]
        public int InvoiceId { get; set; }

        [OneToOne]
        public Invoice Invoice { get; set; }
    }

  public class LineItem : ProfessionalService
    {

        [PrimaryKey, AutoIncrement, Column("_id")]
        public int Id { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public decimal Price { get; set; }

        [ForeignKey(typeof(Invoice))]
        public int InvoiceId { get; set; }

        [ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
        public Invoice Invoice { get; set; }
    }

With the above, no matter what I do I am not able to accomplish

  public async Task InsertInvoiceWithChildren(Invoice invoice)
        {
           await _database.DbConnection.InsertWithChildrenAsync(invoice, recursive: true);
        }

Answers

Sign In or Register to comment.