我有一个分为两个部分文件的类,如下所示:
public partial class PersonRepository : BaseRepository<Person>
{
public static readonly string ColumnID = "ID";
...
Run Code Online (Sandbox Code Playgroud)
和
public partial class PersonRepository : BaseRepository<Person>
{
public List<Person> GetByCompany(int companyID, string sortExpression = ColumnID)
{
...
Run Code Online (Sandbox Code Playgroud)
但编译器一直说sortExpression"必须是编译时常量".对我来说,这似乎是一个完美的编译时常量,所以我不明白问题出在哪里.