Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Do we plan to support the gerenate the SQL text per the Domain object?

Open gaojianzhuang opened this issue 2 years ago • 0 comments

Sometimes the sql string is very simple, but wast time. For example:

public class Customer
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

We have the model and match to a datatable, if we can use the way to get the result that will be awesome.

connection.Query<Customer>();

The SQL text can be gerenated by some strategies.

SELECT
    id AS Id,
    first_name AS FirstName,
    last_name AS LastName
FROM
    tbl_customer

We can defined many different strategies to covner the Domain object to our expected string:

  1. AddPrefixStrategy: add the prefix text to the table or column name
  2. AddSuffixStrategy: add the suffix text to the table or column name
  3. RemoveSuffixStrategy: remove the suffix text of the table or column name
  4. RemovePrefixStrategy: remove the prefix text of the table or column name
  5. ToUpperStrategy: upper the text of the table or column name
  6. ToLowerStrategy: lower the text of the table or column name
  7. ToCamelStrategy: camel the text of the table or column name
  8. WordBetweenUnderscoreStrategy: add underscope text of the between word for the table or column name
  9. CompositeStrategy: the composite for the above strategies.

The expected steps: image

I saw the Dapper.Conrib provide some simple cases, do we have plan to include this feature in the future? Thanks.

gaojianzhuang avatar Apr 04 '22 10:04 gaojianzhuang