How to convert PropertyInfo to property expression and use it to invoke generic method?

前端 未结 3 1336
耶瑟儿~
耶瑟儿~ 2020-12-15 10:22

How to convert PropertyInfo to property expression which can be used to invoke StructuralTypeConfiguration.Ignore(Expression

3条回答
  •  天涯浪人
    2020-12-15 10:46

    TProperty exists only in the c# source code text. The compiler always resolves it to a concrete type. If you have a method

    void Test(T arg)
    {
    }
    

    and call it like this

    Test("hello");
    Test(3);
    

    The compiler generates code for two methods!

    void Test(string arg)
    {
    }
    
    void Test(int arg)
    {
    }
    

    This means that you have to supply concrete types for your generic parameters if you want to have an invokable method.

提交回复
热议问题