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





you declare a private property _appContext which returns _context as MyDBContext
– Pierre
4 mins ago



_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.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV