Browse by Tags
All Tags »
Tips (
RSS)
Yesterday, a developer asked in the LINQ in Action forum and in Microsoft's official LINQ forum how to write a LINQ to SQL query that would return random records from the database. It's not something built-in. There is no Random query operator provided...
Did you know that depending on the way you rethrow exceptions you may lose important information? There are already several blog posts that explain and demonstrate the difference between throw and throw ex . I'm realizing only now that none of the two...
Way too often developers take the easy solution to use try..catch blocks to silence and ignore exceptions. There are two things to do when you see this happening: Explain the developers why it's a bad practice (exceptions are costly and their use should...
Often, when you try to find out how to write the correct LINQ query you need, you end up being confused because it becomes too complex. In such situations, you should remember that the let clause is here to help you. Let's see is an example from the official...
When debugging LINQ to SQL code, did you wish you could easily see the SQL that gets executed? Of course there is the DataContext.Log property that is available for that. You can assign any TextWriter to this property. Console.Out is a good candidate...
Patrick Smacchia, C# MVP, author of the best-seller Practical .NET2 and C#2 and creator of NDepend , has started to blog . In his second post, Patrick proposes a simple trick to rationalize your code environment and build process . Basically, he explains...
As Nikhil Kothari writes in his blog , he's started to use the configSource attribute to split configuration files into smaller pieces. For example, here is how he exports the profile configuration into a dedicated configuration file. This is web...
Luca Bolognese, from the Microsoft C# team, has an interesting post that aims at providing answers to the following question: Which type should I use in C# to represent numbers? Luca and the C# team try to provide a simple algorithm that can help when...
Paul Sheriff has just published an example he uses to recommend the use of try..finally blocks. Here is his example: private void CreateLogFile() { try { StreamWriter sw = new StreamWriter(@"D:\Samples\Test.txt", true, System.Text.UTF8Encoding...
It's often useful to remove diacritic marks (often called accent marks) from characters. You know: tilde , cédille , umlaut and friends. This means 'é' becomes 'e', 'ü' becomes 'u' or 'à'...
More Posts
Next page »