Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 多列上的SQLite ORM主键_C#_Database_Sqlite_Orm_Primary Key - Fatal编程技术网

C# 多列上的SQLite ORM主键

C# 多列上的SQLite ORM主键,c#,database,sqlite,orm,primary-key,C#,Database,Sqlite,Orm,Primary Key,在SQLite中的多个列上指定主键的语法是什么 我正在使用Xamarin在C#中开发一个应用程序,并希望使用SQLite ORM在多个列上使用主键的表 TableObject类定义了一个表。 我想确保ProductID和RetailerID的组合是唯一的。 为了实现这一点,我想将列的组合作为主键 我尝试了以下方法: class TableObject { [PrimaryKey] public int ProductID { get; set; } [PrimaryKey

在SQLite中的多个列上指定主键的语法是什么

我正在使用Xamarin在C#中开发一个应用程序,并希望使用SQLite ORM在多个列上使用主键的表

TableObject类定义了一个表。 我想确保ProductID和RetailerID的组合是唯一的。 为了实现这一点,我想将列的组合作为主键

我尝试了以下方法:

class TableObject
{
    [PrimaryKey]
    public int ProductID { get; set; }
    [PrimaryKey]
    public int RetailerID { get; set; }
    public decimal Price { get; set; }
}
该表的创建方式如下:

database.CreateTable<Cache>();

但是我如何使用SQLite ORM实现这一点呢?

这是不受支持的,您可以在这里阅读:

有些人已经扩展了SQLite PCL以启用一些附加功能

如果数据优先选项可用,您可以尝试使用您建议的模式快速测试数据库,并从模式中创建模型,以查看它在代码中生成的内容。
CREATE TABLE something (column1, column2, column3, PRIMARY KEY (column1, column2));