Skip to content

Add Generic Insert methodsΒ #1270

@praeclarum

Description

@praeclarum

Would be nice to have a generic Insert* set of methods to remove this warning.

This is the result of trimming support added in 1.10 (#1222)

Program.cs(5,7): warning IL2026: Using member 'SQLite.SQLiteAsyncConnection.InsertAsync(Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This method requires ''DynamicallyAccessedMemberTypes.All' on the runtime type of 'obj'.
Program.cs(6,7): warning IL2026: Using member 'SQLite.SQLiteAsyncConnection.InsertAsync(Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This method requires ''DynamicallyAccessedMemberTypes.All' on the runtime type of 'obj'.
using SQLite;

var db = new SQLiteAsyncConnection("users.db");
await db.CreateTableAsync<User>();
await db.InsertAsync(new User { Name = "Alice", Age = 30 });
await db.InsertAsync(new User { Name = "Bob", Age = 25 });
var users = await db.Table<User>().ToListAsync();
foreach (var user in users)
{
    Console.WriteLine($"Id: {user.Id}, Name: {user.Name}, Age: {user.Age}");
}
class User {
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    public string Name { get; set; } = "";
    public int Age { get; set; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions