C# 私有MyDbContext\u appContext=>;(MyDBContext)_context;?
请解释一下这个代码是什么意思C# 私有MyDbContext\u appContext=>;(MyDBContext)_context;?,c#,lambda,dbcontext,C#,Lambda,Dbcontext,请解释一下这个代码是什么意思 private MyDbContext _appContext => (MyDBContext)_context; 非常感谢 private MyDbContext _appContext => (MyDBContext)_context; 是以下属性定义的简写版本: private MyDbContext _appContext { get { return (MyDBContext)_context; } } 更新:更正
private MyDbContext _appContext => (MyDBContext)_context;
非常感谢
private MyDbContext _appContext => (MyDBContext)_context;
是以下属性定义的简写版本:
private MyDbContext _appContext
{
get
{
return (MyDBContext)_context;
}
}
更新:更正:这是一个属性,而不是一个方法此功能被调用
引用Microsoft文档:
如果您选择自己实现一个属性get访问器,您可以
对于简单
返回属性值
使用表达式体定义的只读属性可以是
在没有显式set语句的情况下实现。语法是:
PropertyName=>returnValue
您可以通过调用
\u appContext.Anything()
声明一个私有属性\u appContext
,该属性将\u context作为MyDBContext
返回。您实际调用的((MyDBContext)\u context.Anything()
不是方法的,它是一个属性。