c# - Does using DateTime.Now.Hour Make a linq query local? -


I realized that my code was very slow, because I was performing local queries. But now I am trying to not make all my Linux queries locally. My suspicious code is:

  currentLogs = (cDataContext.DownloadLogs from DLL, where dll.DTS.Hour == DateTime.Now.Hour selection dll); This is a set of questions that hurt me (yes, I know that I can add them, but they are currently different so I can debug easy);  
  var storeLeft = (x from cDataContext.CategoryCountryCategoryTypeMappingsConclusionCodeContext.Categories at x.CategoryID y.CategoryID where (y.StorefrontID == 73) selection X); Int storesLieftCount = (Where to buy from SEL! (Choose not downloaded IDID from NDID ndID.CategoryCountryCategoryTypeMappingID). Include (sl.CategoryCountryCategoryTypeMappingID) SL) .Count ();  

Edit: I should not have even added

  notDownloadedIds = (x to cDataContext.CategoryCountryCategoryTypeMappings where !! Choose y from the current logs .CategoryCountryCategoryTypeMappingID) includes (x.CategoryCountryCategoryTypeMappingID) x); All LINQ queries against EF or LINQ-to-SQL runs on SQL Server  

If your code can not be converted to a SQL query, it throws an exception , "does not run queries locally".

If you run a "local question", then if you implement your query and then execute some LINQ against it.

Your first query will change to currentLogs in SQL like the following:

  SELECT [Extent1]. [DTS] AS [DTS], [Extent 1]. [Field 1] AS [[Field 2] AS [Field 2], [Extent 1]. [Field 3] AS [field 3], [extant 1]. [Field 4] AS [field 4] FOR [DBO]. [Download Lodge] AS [Extent 1] WHERE (DATEPART (Hour, [Extent1]. [DTS]) = (DATEPART (Hour, GetDate ())  

You can use a program called LINQPad It is really useful to check for LINQ questions, and it's free.

The issue with the above question is that any index can help you , So every single line in that table has to be seen,

if you write the following instead Everything will be found and then filing at the local level (which will be damaged):

  insures the query to run the.ToList (), it does so. CurrentLogs = (Select the cDataContext.DownloadLogs dll in dll) .toList (); CurrentLogs = (In Current Locations by DLL, where dll.DTS.Hour == Date time.Now you choose your DLL .) List ();  

There is a problem when debugging that sometimes you will see the query and check the result or something else That will run the query, which can not run in your code, e.g. Your storeLeft will not run on your own at any time, but as shown above, only the storeLiftCount has been added to the query, but if you debug it and see it Probably will run.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -