June 2011 Entries

Use CompiledQuery.Compile to improve LINQ to SQL performance

After reading DLinq (Linq to SQL) Performance and in particular Part 4 I had a few questions. If CompiledQuery.Compile gives so much benefits, why not to do it for all Linq To Sql queries? Is any essential disadvantages of compiling all select queries? What are conditions, when compiling makes whose performance, for how much percentage? World be good to have default on application config level or on DBML level to specify are all select queries to be compiled? And the same questions about Entity Framework ......

Combining javascript files

I’ve read Combining Client Scripts into a Composite Script and wanted to use it. Then I’ve read Julian Jelfs concerns ScriptManager.CompositeScript issues However the article Combining javascript files with Ajax toolkit library describes workarounds, that make the solution workable. You also can use Script reference profiler: http://aspnet.codeplex.com/... Related posts: Using ScriptManager with other frameworks MSDN documentation: CompositeScriptReference The older implementations, ......

Message during Edit and Continue doesn't give an option to edit.

During my Edit and Continue session I received a message --------------------------- Microsoft Visual Studio --------------------------- Modifying a catch handler around an active statement will prevent the debug session from continuing while Edit and Continue is enabled. --------------------------- OK --------------------------- I would expect that Visual Studio give me option to edit, but stop Edit and Continue or Cancel, but it only disallow edit . I've posted the suggestion to MS Connect Related ......

Google Documents have very limited table support

I am using Google Documents for text editing and generally it works quite well. However I've found, that table support is very limited. I've tried to copy and paste single row of the table, but didn't found how to do it properly.(the issue was reported to Google almost 3 years ago) I've switched to Google new spreadsheet and done my table quite easy. However when I tried to paste it to Google doc, it was copied as plain text, not as a table(the issue also was reported more than 2 years ago). Finally ......

Lookup Tables with fallback support

Our database has a few lookup tables that uses similar approach to implemented by .Net Framework for localized resources: At run time, ASP.NET uses the resource file that is the best match for the setting of the CurrentUICulture property. If there is no match for the current UI culture, ASP.NET uses resource fallback. It starts by searching for resources for a specific culture. If those are not available, it searches for the resources for a neutral culture. If these are not found, ASP.NET loads the ......

Generated tests assign enums to enum constructor

When Visual Studio generates tests, for initial value for enums it uses enum constructor. MyClass.TracingMode tracingMode = new MyClass.TracingMode(); // TODO: Initialize to an appropriate value It looks strange. Is it worth to suggest in MS Connect to change the default ......

Does StackOverflow make my blog redundant?

A few years ago I wrote a post describing how I creating many of my blog posts. When I had a new question/issue that required some research, Usually I do a Google search, open a few articles and extract what is useful from them. Usually I was not able to find exact answer, so I had to make a solution of my problem based on the ideas from different articles add my own ideas, combined the ideas from different sources, and finally describe my sollution in a blog post. Recently I realized, that from ......

LINQ: check for null return from function

One of of my colleagues wrote a LINQ query similar to the following: var q=from i in keys select GetTuplesOrPossibleNull(i) into kvp orderby kvp.Item2 select kvp; I’ve noticed, that for some data it throws null exception on kvp.Item2 in orderby statement. It was found that calling function sometimes return null instead of expected key-value pair. I thought where I should insert check for null and my first idea was to add check in where statement before select function call, something like the following ......

Copy HTML documents to Kindle DX

I’ve tried to work out, is it good to use email@free.kindle.com to convert and send documents to Kindle DX. Amazon description is not very clear, and it’s not obvious, that DX doesn’t support WiFi. Finally I understood, that sending to email@free.kindle.com just sends the email to your email address attempting to convert attachments to azw fromat. You can then transfer the document to your Kindle through the USB cable. Keep in mind that IE support to send html page in email body, but not directly ......

Message : A potentially dangerous Request.Path value was detected from the client (:).

We’ve noticed in event log the following error: Message : A potentially dangerous Request.Path value was detected from the client (:). Type : System.Web.HttpException, System.Web, Version=4.0.0.0, Culture=neutral, Message : A potentially dangerous Request.Path value was detected from the client (:). Source : System.Web WebEventCode : 0 ErrorCode : -2147467259 Stack Trace : at System.Web.HttpRequest.Vali... at System.Web.HttpApplication.... ......

Visual Studio:"The following breakpoint cannot be set" message

In Visual Studio I’ve started the application with debugging(F5) and then tried to click url in one of the source code comments. After opening URL within VS I suddently start to receive dosens of messages like the following for each breakpoint that I have: --------------------------- Microsoft Visual Studio --------------------------- The following breakpoint cannot be set: At MyClass.cs, line 836 character 6 ('Namespace.MyClass.MyFunct... line 17) Unknown error. --------------------------- OK ......

Validating an email address

I needed to validate customer email addresses. Many articles suggested to use different regEx , but they are not the same and not easy to identify, which is the best. So i decided to use MailAddress, which throw exception if MS implemented validation failed. It world be good if the class would provide Validate or TryParse method to avoid costly exception. /// <summary> /// //// Validating E-mail address /// </summary> public static class MailHelper { //TODO: use Reflector or find some ......

Implementations of HTML TidyLib for .Net

I was considering to add the HtmlValidator class to codeplex, but noticed that there are a few different implementations of HTML TidyLib for .Net. Not sure if any of them support my requirement to validate only structural errors, i.e. unmatched(not closed) open tags and unmatched(extra) close tags. But standard Tidy functionality will be good for most of users. 1. TidyManaged (https://github.com/markbea... Recent development (June 12, 2010), Positive reviews(e.g. here),Not much user ......

SQL Script to create indexes for Foreign keys

http://stackoverflow.com/qu... I’ve used SQL script similar to paul_nielsen’s to Create Indexes for Foreign Keys and added “if not exists” condition DECLARE @SQL VARCHAR(max); SET @SQL = '' SELECT @SQL = @SQL + 'if not exists (select * from sys.indexes where id=object_id(''' + TableName +''') and name=''Ix' + ForeignKeyName+''') CREATE INDEX Ix' + ForeignKeyName + ' ON ' + TableName + '(' + ColumnName + '); ' FROM ….... --SELECT @SQL ......

JavaScriptSerializer extension DeserializeDictionary

When I've tried to deserialize dictionary whis strongly typed(and not string) keys, I've got an exception similar to the following Type 'System.Collections.Generic... System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d5... mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934... is not supported for serialization/deserialization of a dictionary, keys must be strings or objects. // Type Dictionary`2 ......

Validation of Html file

We’ve used HtmlAgilityPack based function IsValidHtmlFragment(string html) to validate dynamically loaded Html Fragments before inserting into main page(or do not insert if it is invalid) and recently noticed that it doesn’t return false for some fragments with not closed tags. I decided to find some other tool to call from the code and found that most of HTML parcers are too forgivven(like browsers) or too strict- to check full XHTML conformance. I am going to add manual procedure to run Tidy.EXE ......

«June»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789