Open shps951023 opened 3 years ago
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)'
record:
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;
}
//..
}
Like Dapper:
record