|
I am trying to understand the DbContext class by going to its definition and look at its members.
I am confused by what I saw in DbContext's definition, all of the methods in the DbContext class only have method signatures but no body (no implementation). Please see some of the methods below.
public virtual int SaveChanges();
public virtual DbSet Set(Type entityType);
Can someone please explain why all of the methods in the DbContext class look like they are abstract methods in an abstract class or methods in an interface. If these are concrete methods why don't they have implementations?
modified 31-Dec-16 12:28pm.
|
|
|
|
|
I don't know what you're looking at but those do have implementations. They're overridable, but they do have default implementations.
Examine the source for DbContext here[^].
|
|
|
|
|
Can you give us the whole structure of the class you are looking at? You are looking at wrong place I guess.
|
|
|
|
|
Hi, thank you for replying. I have a class that inherits from the DbContext class and to go to DbContext class definition, I placed the cursor on DbContext and pressed F12.
For the most part the definition of DbContext that I saw looked like the one shown in the link provided by Dave Kreskowiak above. The only problem is that none of the methods have implementations.
modified 30-Dec-16 12:11pm.
|
|
|
|
|
You're looking at the peek definition window. It shows the definition for the type or method symbol your cursor is currently on. It can not show implementation code it doesn't have access to like in an external DLL. In that case it only displays metadata.
|
|
|
|
|
hello Friend i have to know how to split below string in particular part. i have find this type of string in bar-code scanner as a input
I have a input
Hide Copy Code
0.1042.5140.7043.037.000.005.063.613.761.70.062
and i want output
0.104
2.51
40.70
43.0
37.00
0.00
5.0
63.6
13.7
61.7
0.06
please help me to solve this.
|
|
|
|
|
So you're looking at positional indexing. In other words, get the string from position 0 to 4 then 5 to 8 and so on. The string class has many features that could make this life easier for you but, if I were you, I would look at the Substring[^] command.
This space for rent
|
|
|
|
|
What is the basis or pattern for the split? You example appears random.
Peter Leow
http://www.peterleowblog.com/
https://www.amazon.com/author/peterleow
|
|
|
|
|
string s = "0.1042.5140.7043.037.000.005.063.613.761.70.062";
List<int> widths = new List<int>() { 5, 4, 5, 4, 5, 4, 3, 4, 4, 4, 4 };
int index = 0;
widths.ForEach( w => { Console.WriteLine( s.Substring( index, w ) ); index += w; } );
|
|
|
|
|
thanks a lot substring work for me.
|
|
|
|
|
How to disable the keys while the system is in idle time ?
How to count the idle time of a user ?
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So why would you want to disable the keyboard when the system is idle, given that the system will only become "busy" again in response to events - one of which is the user typing on the keyboard?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
There's a difference between an idle user and an idle system, and normal applications cannot disable all keys.
What are you trying to achieve?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Windows (API) mouse and keyboard hooks.
|
|
|
|
|
Ummm... why on earth would you disable a keyboard that isn't being used at the time?
|
|
|
|
|
|
I know that Func<t,tresult> is a delegate that takes T as a parameter and returns TResult as an output but I do not know what the following means.
Expression<Func<T, TResult>>
Can someone please explain what the above syntax means and how it is used.
modified 27-Dec-16 17:50pm.
|
|
|
|
|
|
Hi, thanks for replying. Your link does not help me understand what an Expression is in C# or how to use it.
I came across a method the other day and I was trying to find out what the syntax is trying do. I've been looking at tutorials on Expression on Youtube and Google but it didn't really help.
The following is the method I mentioned but I don't really know what it is supposed to do.
public IEnumerable<T> Find(Expression<Func<T, bool>> predicate)
{
return Context.Set<T>().Where(predicate);
}
modified 28-Dec-16 10:31am.
|
|
|
|
|
In what you have posted here it allows you to pass a lambda statement as the argument. For example
MyClass.Find(p=> p.id == 12);
or
string[] toInclude = new string[] { "Hi", "Why", "Bye"};
MyClass.Find(p=> toInclude(p) == true);
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Expression<Func<T, TResult>> represents a strongly-typed expression tree of a lambda or function. Expression trees represent expressions like a < b stored in a tree structure. So what are they used for? Well, that's open to your imagination honestly. A common scenario is if you want to modify a code expression based on some currently unknown or later business logic. Since an expression tree is a data representation of a code expression you're free to modify it before calling Compile() and executing it. This is essential for LINQ-to-SQL which transforms expressions like from a in db.table select a into an expression tree which is then transformed into the necessary SQL for the actual DB call. Expression trees are also heavily used in the Dynamic Language Run-time.
As far as the specific example in your other post:
public IEnumerable<T> Find(Expression<Func<T, bool>> predicate)
{
return Context.Set<T>().Where(predicate);
}
Context is most likely a DbContext object. Set<T>() returns a DbSet<T> of all entities of the type given to Set . Then Where is called to filter the result based on the predicate expression which, instead of just being a lambda, is stored as an expression tree - I'm guessing because of some other logic elsewhere in the application otherwise this seems a little over-the-top.
EDIT: Forgot to add how to use them. In LINQ you treat it like any other function. Outside of LINQ you call Compile() to create the Func delegate. To create them is as simple as assigning a lambda in simple cases. For example, Expression<Func<int,int>> incrementTree = a => a + 1; . In more complex cases, you may need to explicitly use the expression tree API which you can find links to in the MSDN guide below.
Further reading:
Expression Tree Basics
Expression Trees - MSDN
|
|
|
|
|
|
|
Cela est normal avec windows10 pour une application universelle car c'est le système d'exploitation qui gère la permission de l'utilisateur OK bien !!! Mais mon application est automatiquement compatible Windows 8.x lors de la soumission au store et il échoue puisque avec 8.x c'est le programmeur qui gère l'autorisation avec le code:
Var accessStatus = await Geolocator.RequestAccessAsync (); demande d'accès
Switch (accessStatus) // test d'accèsStatus
Dans visual studio 2015 aucune définition dans geolocator pour requestaccessasync (), (seulement "égal" et "égal de référence") quelqu'un saurait comment contourner ce problème je cherche depuis une semaine.
je doit donc tester si ce n'est pas windows10 (ça d'accord) et dans ce cas demander l'autorisation d'accéder à la geolocalisation à l'utilisateur qui devrait se faire avec le code çi dessus mais c'est impossible je suis donc dans une belle impasse.
je vous souhaite à tous de bonnes fêtes.
bonnes fêtes à tous
|
|
|
|
|
This is an English language site, and we can only answer questions in English.
Please try using Google Translate:
This is normal with windows10 for a universal application because it is the operating system that manages the permission of the user OK well !!! But my application is automatically compatible Windows 8.x when submitting to the store and it fails since with 8.x it is the programmer who manages the authorization with the code:
Var accessStatus = await Geolocator.RequestAccessAsync (); Request for access
Switch (accessStatus) // access testStatus
In Visual Studio 2015 no definition in geolocator for requestaccessasync (), (only "equal" and "reference equal") someone would know how to get around this problem I've been looking for a week.
I have to test if it is not windows10 (that agrees) and in this case ask permission to access the geolocation to the user who should be done with the code above but it is impossible I I am therefore in a beautiful dead end.
I wish you all a happy holiday.
Happy Holidays to all
But it doesn't make a lot of sense to me even translated - it looks like an attempt at an answer in parts, but to what I am not sure...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|