private MyDbContext _appContext => (MyDBContext)_context;?
private MyDbContext _appContext => (MyDBContext)_context;?
Please can some explain what does this code means ?
private MyDbContext _appContext => (MyDBContext)_context;
Thanks alot
_appContext
_context as MyDBContext
By calling
_appContext.Anything()
you actually call ((MyDBContext)_context).Anything()
– Pierre
2 mins ago
_appContext.Anything()
((MyDBContext)_context).Anything()
1 Answer
1
Basically its an Expression-bodied member introduced in C# 6
Expression body definitions let you provide a member's implementation
in a very concise, readable form. You can use an expression body
definition whenever the logic for any supported member, such as a
method or property, consists of a single expression. An expression
body definition has the following general syntax:
So its equivalent is
private DbContext _contex;
// just a method to cast to your MyDBContext
private MyDbContext _appContext
{
return (MyDBContext)_context;
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
you declare a private property
_appContext
which returns_context as MyDBContext
– Pierre
4 mins ago