Skip to content

Dapper.Contrib Get should select list of columns #482

Description

@xmedeko

I have a SQLite table

createtablecars (
id integerprimary 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

publicclassCar{[Key]publiclongId{get;set;}publicstringName{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

selectt.id, t.namefrom 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.ContribGet query reads the column, but Update, Insert wont change the [Computed] column.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions