Zeeshan Hirani
-
Partial Methods
Partial methods is a new feature available in C# 3.0. Partial methods allow hooks into automatically generated code. Partial method basically consist of definition and implementation. Usually you define and declare partial method in one partial class and implement in another. Partial methods are heavily used by code generated from linq to SQL.
-
Static Classes in C# 2.0
In C# 1.0 if you wanted to ensure that no outside user can create an instance of class and that class user should use static method or properties to use the class, you would normally mark the class as sealed and make the constructor private. When you make the constructor private, no outside user can create an instance of the class. Marking the class as sealed prevents any outside user to extend the behavior of the class. However the draw back to this approach is having two change two things and secondly you can get away with declaring instance level properties or method without compiler raising an error. Obviously those methods and properties are pretty much useless since no one can create an instance of the class. Here is how you would create the class in C# 1.0.
-
Loading Child Entities With Deferred Loading Turned Off
If you have a situation where you do not want to risk your code making too many database calls without you knowing about it. You have the ability to turn off deferred loading by setting DefferedLoadingEnabled to false. However when you set it to false, you loose the ability to fetch that object or collection of objects anymore. What you can do is take control of loading those child entities in your query explicitly. Let's look at an example where deferred loading is turned off and the results you get when you access the child collection.
-
Group by multiple columns in Linq To SQL
Today I was writing a Linq query in which I wanted to applying grouping to query based on more than 1 column and also apply filter on the group more like having clause. After some playing I figured it out. Here is a simple demonstration of grouping by more than 1 column using customer table from NorthWind database.
-
Action delegate in C# 2.0
I have used in the past predicate delegate, which is used when you want to test for a certain condition. However Action delegate is used when you want to perform certain action on specified value. The specified value could be complex type or value type. It could be printing to console window or modifying the current object or value. Here is simple example in which I am making use of Action<T> delegate.
-
Exposing Product Catalog as Syndication Feed Using WCF
In this example I will demonstrate how to expose product catalog as syndication feed using either atom or rss. I will start of with creating a new syndication library as shown below.
-
Using Linq To SQL with ObjectDataSource Control
In my previous blog posting I showed how to use linqdatasource with gridview,detailsview and formview to insert, update and delete records using NorthWind context. Linqdatasource is a nice control to have, however I feel that it forces me to put too much business logic in my aspx file. Not only that, it also forces me to expose my datacontext to my presentation layer. In this small example I making use of ObjectDataSource control to insert,update delete and select records using my business objects.
-
My vacation pictures
I had a really good time during my vacation at disney. I had been meaning to post my vacation pictures but have been really occupied at work and learning new stuff. Finally i was able to find sometime to get all the pictures uploaded to flick.
-
Using Linq To SQL With WCF Service
The other day I met someone in the usergroup who asked me if I know how to use Linq to SQL classes in wcf and if Linq to SQL classes were serializable over the wire. I haven't done any wcf except attended quite a few talks on WCF. I decided to research of what I need to do to consume my Linq to SQL classes using wcf service with asp.net as a presentation layer. Here is a small walk through that illustrates an example of that. I am going to be demonstrating the example using Customer class from NorthWind database.
-
Should I use linq to Sql as a DTO or Business Objects
I was surfing the web, when i came across this article that talks about the pros and cons of using linq to sql as DTO or business objects. It's a nice read.