|
I think you really need to read up on Drag and Drop[^] first. A lot of what you're talking about already happens in a normal drag and drop operation.
You'll get a list of filepaths. Use the System.Io.Path class to figure out what those files/folders are.
|
|
|
|
|
Hello !
I have only 1 problem :
In the DragEnter Event ,I have an instruction like this :
.....
Dim ext = System.IO.Path.GetExtension(files(0))
If Not ( ext.Equals(".xlsx", StringComparison.CurrentCultureIgnoreCase) Or ext.Equals(".xls", StringComparison.CurrentCultureIgnoreCase)) Then
e.Effect = DragDropEffects.None
Return
End If
.....
The problem is that with this code , I'm expecting that all the drag operation that not contain .xls or .xlsx will be cancelled .
But I have a strange behavior : All the other files that doesn't have .xls or .xlsx are blocked to drag-drop , except the .txt files. The files with .txt extensions will still be drag drop.
Why ?
Thank you !
|
|
|
|
|
Well, that's not all the code in the DragEnter event.
And you're only checking the first filename extension with files(0) .
|
|
|
|
|
Hello !
I'm creating an application in VB.net 2013 , with entity Framework 6 and SQL server 2008R2.
I have noticed that every query that run for the first time ( against a specific entity ) , is too slow comparing with other queries.
For example :
Dim query= ( For t in context.Mytable1 where t.nr>5 select t).Tolist --------- Read only 1 records - 25 seconds
Second execution
Dim query= ( For t in context.Mytable1 where t.nr<5 select t).Tolist --------- Read 400 records - 2 seconds
If I try to execute a query against another entity , it's the same scenario , the first time is too slow.
I have tried to use pre-generated views using a tool on NuGet , but there;s no difference.
What can I do ?
Thank you 1
modified 25-May-15 3:51am.
|
|
|
|
|
You are not comparing like for like, the two queries are different. The first includes a where clause, which means the database must read every record and test for that condition. The second query just extracts all records.
|
|
|
|
|
it's just a mistake on typing. I have corrected in my question.
I try 2 queries with different condition , just to show that even the second query read more records , it's faster.
Of course , If I do the same query the first and the second time , the second time is faster.
|
|
|
|
|
How does one query return only 1 record, but the same query run later returns 400? Or is that another typo? It may be that information is cached in the server, so it is found faster the second time.
|
|
|
|
|
The first query has the condition >5 , the second query has the condition <5.
It's not the same query.
|
|
|
|
|
Then you are still making different comparisons so your test is not valid.
|
|
|
|
|
Sorry but if you can see the 2 query are very similar , and different only by the condition.
Anyway , the general problem is this :
The first query executed against an entity is too slow , the others are faster.
The same thing when executing query for the first time against other entities.
|
|
|
|
|
Richard MacCutchan wrote: The first includes a where clause, which means the database must read every record and test for that condition.
Not if you have a reasonable index on the table.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How did you measure it being "too slow"? Did you find a "faster" way?
It may be faster the second time for a number of reasons, like having an open and authenticated connection, having the table in cache, SQL Servers' optimizer, SQL Servers' memory being paged from disc, etc. Yes, with 401 records, SQL Server will have to look at all the records - but should be fast indeed once they are in the cache - depending on the column-definition, it may hold the entire table there.
Of that first query, how long is it really executing the task on SQL Server, and how does that compare to the total waiting time?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
On top of what everyone else has said, Entity Framework itself has a "warm up time" with the very first query your app makes each time the app is launched. This is where Entity Framework is going through the entity classes and compares the structure against the database to make sure nothing changed. Obviously, this takes time.
If you really wanted to compare apples to apples, you have to get Entity Framework to make a different query first, one where you're going to throw the results away, just to get EF through its warm up time.
The only catch, EF6 has a pretty short warm up time, a few seconds for most models.
|
|
|
|
|
Ok , but how to force EF to do this "Warm Up Time" on another moment for example at program startup , because the user is better to wait some more time at program startup than when he need to do a specific job.
Yes , I can call a query , but what if the entities number is too high ?
|
|
|
|
|
I already told you how.
satc wrote: but what if the entities number is too high ?
It doesn't matter at all. You just have to execute a single query, ANY query against the database, even if it doesn't return any records. That is enough to get EF to do it's warm up work.
|
|
|
|
|
I think that's not true.
I wrote in my original question , that if I execute a query against a entity fro the first time , it need more time , second time it's faster.
But after if I try to execute another query against another entity for the first time , it's the same situation , this first query it's slower , and after the queries are faster.
And if at some point I do
context = new myentities
the situation is repeated like in the beginning.
|
|
|
|
|
I did not say that it was the cause of your problem.
All I said was Entity Framework has a warm up time to validate the database against the object model on the first query.
I have no idea what's causing your entire problem, other than probably bad indexing on the database. You have to setup any appropriate indexes on the database tables yourself. Entity Framework won't do it for you.
|
|
|
|
|
I've already done the indexing.
But anyway , I think a bad indexing would cause problems every time , not only the first time.
|
|
|
|
|
Dave Kreskowiak wrote: Entity Framework itself has a "warm up time" with the very first query Just another nail in the EF coffin. What a POS.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Not like I had experience with a lot of different "heavy weight" ORMs but I can't imagine how it could be any different unless you/it deliberately skip(s) schema validation. And I don't think it's a big deal given it's a one time thing. There are probably other things more worth complaining about
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Sascha Lefèvre wrote: There are probably other things more worth complaining about Hence the comment "another nail". I loathe over engineered, black box tools, I use them where they are the only viable alternative (UI controls from telerik) but a DAL/ORM/Kitchen Sink I can do without.
I have a data access class that is an 18k DLL that does 98% of my LOB work.
I have a ORM tool that is not included in the app an writes 90% of my WCF, various UI classes, it will produce the xaml for Telerik grids and enums for master tables. And it does not need "warm up time"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well, I'm using it in a web app that has about 115 entity classes (tables) all on one context. The warm up time of EF6 is about 2.5 seconds. I don't consider it bad.
It makes the bulk of my work easier but it does have some downsides. The SQL it generates isn't the most efficient when thing get complicated and the change tracker isn't the fastest thing in the world but it does the job for my site, does it reliably well and does it within performance specifications.
I'd use it again for another project, depending on requirements, but there are a couple things I'd do differently, such as breaking my monolithic context into smaller contexts. I'd get a bit quicker warm up time, but I'd also get one with each context.
|
|
|
|
|
I dislike the reliance such a comprehensive tool engenders in junior devs, they build apps based around such tool and never really understand their data and how it is stored and retrieved. I'm old school, especially around the database and how it is designed and works.
Just looked at one of our apps, 112 tables, each with 2 stored procs (old school ) and about 50% with a view.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't understand very well what do you mean.
So as you are "old school" , give me a counsel : On your opinion , should I use Entity Framework or not ?
|
|
|
|
|
Personally I would never recommend an aspiring developer use EF, you do not get to know your data structure and transport layer, EF does all the work for you.
However there are a lot of well respected devs that DO use it, but then they already have a deep knowledge of what the tool is doing.
You need to decide if you are going to be a tool user or a true developer with a deep understanding of your work. Time is also a constraint.
Never underestimate the power of human stupidity
RAH
|
|
|
|