Posts

Showing posts from August, 2010

Design Patterns

The following link explains four design patterns using real time example. 1) Observer Pattern (Behavioral) 2) Strategy Pattern (Behavioral) 3) Decorator Pattern (Structural) 4) Builder Pattern (Creational) http://amazedsaint.blogspot.com/2008/01/design-patterns-part-i-and-ii.html

How to sort AlphaNumerics values in SQL Server?

Column Name [Revision] with Alphanumerics. Type – varchar(5) Sample Data as follows: A B 1 10 2 30 4 5 6 7 10 C D  Sort Revisions by Order By clause: Select Revision from [#Table1] ORDER BY CASE WHEN Revision LIKE '%[^0-9]%' THEN 99999               ELSE CONVERT ( INTEGER , Revision ) END , Revision Above query select revision and if revision is not numeric value, assigns 99999 values for nonnumeric data. If Revision has numeric value it converts into Integer and Orders the Revision value.

Generate ADO.Net Entity Framework Connection String on RunTime

When application uses ADO.Net Entity framework, by default connection string saves in web.config file. We can delete the default connection string from web.config file and pass the connection string to the context object as follows.   using System.Data.SqlClient; using System.Data.EntityClient; //ConnectionString would be normal sql connection string  string connectionString = ConfigurationManager .ConnectionStrings[ "ConnectionString" ].ConnectionString;                SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder (connectionString); EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder (); entityBuilder.Provider = "System.Data.SqlClient" ; entityBuilder.ProviderConnectionString = sqlBuilder.ToString(); entityBuilder.Metadata = @"res://*/Entities.csdl|res://*/ Entities.ssdl|res://*/ Entities.msl" ;   EntityConnection conn = new EntityConnection (entityBuilder.ToString());     us

Create ADO.Net Entity Framework Complex Type

Complex Type creation in ADO.Net Framework: http://blogs.msdn.com/b/nihitk/archive/2010/04/23/ado-net-entity-designer-in-vs-2010-stored-procedure-return-type-shape-sensing.aspx Table Valued Functions Mapping: http://blogs.msdn.com/b/efdesign/archive/2011/01/21/table-valued-function-support.aspx

ADO.Net Entity Framework vs Linq to Sql Classes

http://www.scip.be/index.php?Page=ArticlesNET12