Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to July 2009 Entries
Declare local variable within the loop instead of using loop variable in Linq methods
I've noticed in my LINQ code Resharper Warning "'Access to modified closure'". The search pointed that there is very confusing potential error. If for/foreach loop variable is used only in Linq methods (more general, only as a parameter for delegates) , only the last value of the variable will be used for all calls. It always required to create local variable inside loop and use the local variable instead of loop variable. More about the issue: Linq: Beware of the 'Access to modified closure' demon ......

Posted On Saturday, July 18, 2009 7:47 AM

Implement Copy constructor using Serialization or Reflecton
Some time ago I wrote a post No Copy Constructor support in .Net framework. and was adviced by Tim Hibbard to use reflection like this. I've created Copy method to copy Fields(not only properties, and found that the private fields of any base class are not copied. The article Where are my fields? « Andrew Smith explains that it's required to iterate base classes. But when looking in the Google for the solution,I've found the suggestion for serializable objects: MemberInfo [] sm = FormatterServices ......

Posted On Friday, July 17, 2009 6:01 PM

Text from SQL Management Studio reformatted by Google Docs when using IE.
When I am using Google Docs, quite often I am copying the portion of code from Visual Studio or SQL Management Studio. but the text is reformatted to become messy. E.G. ALTER PROCEDURE [dbo].[CheckNotProcessed] @limit int = 10 AS declare @StartDate datetime declare @EndDate datetime declare @NotProcessedCount int is shown as ALTER PROCEDURE [dbo].[CheckNotProcessed] @limit int = 10 AS declare @StartDate datetime declare @EndDate datetime declare @NotProcessedCount int I've tried to manually insert ......

Posted On Saturday, July 4, 2009 7:46 AM

Custom alert on the SQL Database
I wanted to create a custom alert on the SQL Database when number of records with some values(considered as invalid) exceeds the expected limit. First of all you need to Set up Database Mail for SQL 2005 and follow procedure How to setup SQL Server alerts and email operator notifications IMPORTANT: don't forget to Restart SQL Agent to activate settings. Similar to the article Define custom error messages in SQL Server 2005 I've defined the error EXEC sp_addmessage 60001, 1, N'Number of not-processed ......

Posted On Saturday, July 4, 2009 7:07 AM

MSbuild Task FileUpdate to replace content in text files
I wanted to replace some strings in files using my deployment MSbuild script. I've noticed that MSBuild Community Tasks Project has RegexReplace task. But when I've looked in documentation (By the way, it will be good if Reference help will be available online, not only from download) I've realized that the task is applicable for strings(e.g file names) not to content within a file. Almost accidently in one of the posts i've found a reference to FileUpdate task, that support Regex and does content ......

Posted On Friday, July 3, 2009 8:45 PM

Copyright © Michael Freidgeim | Powered by: