Postări

Se afișează postări din mai, 2015

Fast POCO Class direct from SQL Management Studio

Create fast POCO class from SqlServer with this. Sweet! declare @TableName sysname = 'MyTableName' declare @Result varchar(max) = 'public class ' + @TableName + ' {' select @Result = @Result + '     public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; } ' from (     select         replace(col.name, ' ', '_') ColumnName,         column_id ColumnId,         case typ.name             when 'bigint' then 'long'             when 'binary' then 'byte[]'             when 'bit' then 'bool'             when 'char' then 'string'             when 'date' then 'DateTime'             when 'datetime' then 'DateTime'             when 'datetime2' then 'DateTime'             when 'datetimeoffset' then 'DateTimeOffset'             when 'decimal' then 'decimal'             when

Logging part I

Welcome to logging part I Recently I had a nasty error in production on an asp.net web site application that gave me an error only on one page :) So because this was on production and I was in a very big harry I had to do something fast. The only thing I could think of was to add on the fly ( because it is a web site project each page was compiled at access time - yes the project did not have a global error handler - we'll get there ) I added on the page this: void Page_Error(object sender, EventArgs e) { System.IO.File.WriteAllText(@"C:\Dev\ErrorLog.txt", Server.GetLastError().ToString()); } On the next publish (web site) just put the Global.asax file in the project either add the file with File / Add New and search global application in search and chose Global.asax file. In the appropriate Application_Error section say: public static void InsertText ( string path , string newText ) { if ( File . Exists ( path )) { st