SQLite with foreign keys on Windows 8

Category: windows phone howto

Question

Alexey Starchikov on Tue, 27 Nov 2012 06:44:38


Hi.

I have imported data from my MS SQL Server Compact to SQLite with such sql-query:

CREATE TABLE [Category] ([_parentCategoryId] int NULL, [CategoryID] INTEGER NOT NULL, [Name] nvarchar(4000) NOT NULL, [IsIncome] bit NOT NULL, [Description] nvarchar(4000) NOT NULL, CONSTRAINT [PK_Category] PRIMARY KEY ([CategoryID]), FOREIGN KEY ([_parentCategoryId]) REFERENCES [Category] ([CategoryID]) ON DELETE NO ACTION ON UPDATE NO ACTION);

I have a class for this table:

public class Category: INotifyPropertyChanging, INotifyPropertyChanged
{
public int? _parentCategoryId { get; set; }
...
public Category ParentCategory
{...}
}

But when I getting table from database property ParentCategory is always null:

var list = db.Table<Model.Category>().ToList();


Any suggestions?