sqlite-net-extensions - InsertWithChildrenAsync
Issue #134
new
I'm trying to create a table using the "sqlite-net-extensions". But the problem is always returning with error.
The error that returns is "Read only".
I created two models to create the tables.
Model --> Login
[PrimaryKey, AutoIncrement, Column("login_id")]
[Indexed(Name = "LoginId", Order = 2, Unique = true)]
public int Id { get; set; }
[NotNull, Column("login_user")]
[Indexed(Name = "LoginId", Order = 1, Unique = true)]
public string UserName { get; set; }
[NotNull, Column("login_password")] public string Password { get; set; }
[OneToOne("login_id", "Login")]
public User User { get; set; }
Model --> User
[PrimaryKey, AutoIncrement, Column("user_id")]
public int Id { get; set; }
[NotNull, Column("user_name")]
[Indexed(Name = "UserId", Order = 3, Unique = true)]
public string Name { get; set; }
[NotNull, Column("user_email")]
[Indexed(Name = "UserId", Order = 2, Unique = true)]
public string Email { get; set; }
[ForeignKey(typeof(Login)), NotNull, Column("login_id")]
[Indexed(Name = "UserId", Order = 1, Unique = true)]
public int LoginId { get; set; }
[OneToOne("login_id", "User", CascadeOperations = CascadeOperation.All, ReadOnly = false)]
public Login Login { get; set; }
Insert method
public async Task InsertWithChildren(object o)
{
var connection = _sqliteWrapper.OpenDatabase();
await connection.InsertWithChildrenAsync(o, recursive: true);
}
Comments (2)
-
-
reporter I put in androidmanifest.XML
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I tried giving permissions on the file. In the adb shell, using the command chmod -f 777 <name_file>
The two alternatives do not work. I made an insert with sqlite-net-pcl and it worked.
I believe the problem is in lib.
- Log in to comment
Do you have write permissions to the database file? That error is not raised by this library.