How to use SQLite-Net Extensions with Composite keys

后端 未结 1 1854
不思量自难忘°
不思量自难忘° 2021-01-26 12:01

I have the following class:

Class1.cs:

[JsonObject(MemberSerialization.OptIn)]
public class Class1
{
    [PrimaryKey]
    [JsonProperty(\"key1\")]
    pu         


        
相关标签:
1条回答
  • 2021-01-26 13:00

    First, thank you for your contribution to MvvmCross SQLite Community plugin.

    Sadly, there's currently no support for composite keys in SQLite-Net Extensions, only MvvmCross implementation of SQLite-Net supports multiple primary keys and it's a very recent change.

    I'll take a look at the changes required to support it, but it will take some time. SQLite-Net Extensions was built on top of the assumption that primary keys were unique and therefore foreign keys would be unique per relationship too. This adaptation would require some deep changes in the architecture and the API.

    I'm thinking in something like this to avoid changes in currently working public API:

    [CompositeForeignKey(typeof(Class1), "key1", "key2", "key3"]
    public Tuple<int, int, int> Class1Key { get; set; }
    

    I've created a new issue in the project to keep track of the status.

    0 讨论(0)
提交回复
热议问题