MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

Type Query support multi parameter constructor and record

Open shps951023 opened this issue 4 years ago • 8 comments

Like Dapper:

image

image

record image

shps951023 avatar Jun 24 '21 07:06 shps951023

MiniExcel :

CS0310 'UserQuery.MyClass' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'MiniExcel.Query<T>(string, string, ExcelType, string, IConfiguration)'

image

image

record: image

shps951023 avatar Jun 24 '21 07:06 shps951023

public record MyUser(int Id, string FirstName, string LastName);

record will generate code like :

public class MyUser : IEquatable<MyUser>
{
    private readonly int _Id;
    private readonly string _FirstName;
    private readonly string _LastName;

    public int Id { get => _Id; init => _Id = value; }
    public string FirstName { get => _FirstName; init => _FirstName = value; }
    public string LastName { get => _LastName; init => _LastName = value; }

    public MyUser(int Id, string FirstName, string LastName)
    {
        _Id = Id;
        _FirstName = FirstName;
        _LastName = LastName;
    }
    //..
}

shps951023 avatar Jun 24 '21 07:06 shps951023