Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Foreign Keys in Sqlite.net

$
0
0

I have a cross platform app using Sqlite.net. How do I go about declaring a FK? Say I have these tables, with a FK from Area to Location (and a self referencing FK from Area to Area via ParentID), and ignoring the fact that the IDs are Guids, that is a constraint I inherited from the client and cannot change, although I could declare them as strings) :

public class Location
{
    [PrimaryKey]
    public Guid Id { get; set; }    
    public string Label { get; set; }
}

public class Area
{
    [PrimaryKey]
    public Guid Id { get; set; }
    // self refrerence FK
    public Guid? ParentId { get; set; } 
    public string Label { get; set; }

    // the FK to Loaction
    public Guid LocationId { get; set; }

    //public ICollection<Area> Children { get; set; }
    //public ICollection<Task> Tasks { get; set; }
}

How would I go about declaring the two FKs in Area?

John


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>