Skip to content

Dapper.Contrib Get should select list of columns #482

@xmedeko

Description

@xmedeko

I have a SQLite table

create table cars (
    id integer primary key,
    name text,
    data text);

Where data is a large clob and do not want to read it in every query. I have a class

public class Car
{
    [Key]
    public long Id { get; set; }
    public string Name { get; set; }
}

And read a Car by the Dapper.Contrib query

connection.Get<Car>(id);

It generates the SQL query

select * from cars where Id = @id

It's is not optimal, since the data column (large) is fetched too, and never used. I would expect the query

select t.id, t.name from cars t where Id = @id

I.e specify the columns in the select clause. The GetAll() method should has to be changed, too. (IMHO no ORM should use select * in it's core functions.)

Note: the [Computed] columns has to be omitted, too. With [Computed] the Dapper.Contrib Get query reads the column, but Update, Insert wont change the [Computed] column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions