As the Title says i defined my member, for example my Id, as an Observable Property with the CommunityToolKit.MVVM
[ObservableProperty]
private int id;
But now i am trying to give my Observable Property [PrimaryKey,AutoIncrement] from the SQLite Extension. But i cant just write it like that cause we have no self defined Get/Set only the generated one. Is there a way to add that annotation while it still is an ObservableProperty?
I Imagine it something like that:
[ObservableProperty]
[PrimaryKey, AutoIncrement]
private int id;
CodePudding user response:
No, you can't use the two attributes at the same time. The ObservableProperty need the property without get set method. But the sqlite need it. It's a conflict between them.
So you may need to use the codes such as:
[PrimaryKey, AutoIncrement]
private int id { get; set;}
public int Id
{
get => id;
set => SetProperty(ref id, value);
}