Wriju's BLOG

.NET, Cloud and everything

ADO.NET Entity: Insert Update and Delete

For small blogs, it requires more references and explanation, which sometimes are redundant. So I thought of writing single blog which is combination of topics more or less related to one thing.   I am exploring ADO.NET Entity Framework and have been trying things out there. Here I am planning to demonstrate how to do… Read more

Visual Studio 2008 Express ISO image download

As usual Express editions are free but this time you can take this and sit in a remote location and install Visual Studio with no Internet connections. Yes we can download offline .iso to avoid download & install pain. Please visit, http://www.microsoft.com/express/download/offline.aspx After downloading you can write them in DVD. This version includes all the… Read more

How to find public key token for a .NET DLL or assembly

Many times we need to get the Public key token for a strongly named assembly in .NET. FAQ on that “how to get the public key token?”. Answer is very simple use the .NET Framework tools sn.exe. So open the Visual Studio 2008 Command Prompt and then point to the dll’s folder you want to… Read more

Generics : An easy way to bind the data in DataGridView

Applied to: Visual Studio 2005 [C#]   Yes this is Generics. The concept which helps us to create collection easily and elegantly. Two steps to create the list is demonstrated here.   Step 1:   You have one object say for list of products which contains three properties Name, Quantity and Price.   using System;… Read more

Immediate Window is missing in Visual Studio Menu

  When you do not see “Immediate” window under Debug menu of Visual Studio you may get frustrated. But there is a quick way to get it when required,   Go to View > Other Windows > Command Window or press Ctrl+W, A   Then type immed. It will bring the Immediate Window.   And… Read more

ADO.NET Entity: Insert Update and Delete with Relationship

Few days back I had written an article on Insert/Update/Delete for simple standalone tables at ADO.NET Entity: Insert Update and Delete. Now after that many of you had requested me to put article on how it works with relationship.   Here I will use a database created by me. There will be two tables connected… Read more

LINQ to SQL vs. ADO.NET – A Comparison

ADO.NET is our contemporary data access component and now we have written many applications. Now there has been a lot of talk on LINQ to SQL. So we are little skeptical about this component and trying to find some relation between existing ADO.NET technology.   Purpose of this post is to give some quick brief… Read more

Changing the SiteMapDataSource’s XML filename at runtime

  Applies to: ASP.NET 2.0   ASP.NET 2.0 comes with set of very rich navigation controls like TreeView, Menu, SiteMapPath. Ideally these controls should load the values at runtime from any structured data sources, be it SQL or XML or TXT. The default and most commonly used provider is XmlSiteMapProvider which accepts the data from… Read more

LINQ to SQL : Using Transaction

LINQ to SQL uses optimistic concurrency be default. LINQ to SQL is pure in memory operation, because you normally get the data from database and store them in .NET memory and perform some pure in memory update to those objects and finally when you are done with your modification you give those data back to… Read more

Using Repository Pattern in Entity Framework

One of the most common pattern is followed in the world of Entity Framework is “Repository Pattern”. Since this is something which is heavily used and being practiced, I am not going to talk about the core pattern. Rather, try to show how one can implement it. Objectives As mentioned in http://msdn.microsoft.com/en-us/library/ff649690.aspx You want to… Read more

Orcas March 2007 CTP Error: Unable to find the requested .Net Framework Data Provider. It may not be installed.

  If you have installed Orcas March 2007 CTP and trying to play with SQL Server 2005 Express database using the IDE feature. You might meet with an error mentioning “Unable to find the requested .Net Framework Data Provider.  It may not be installed.” while trying the below mentioned steps   In Server Explorer, Add… Read more

LINQ to XML : Creating complex XML through LINQ

We can generate hierarchical object graph in our memory though LINQ. To be more realistic we can bring data from relational database. So if we consider Northwind database and use LINQ to SQL to bring all the Customers and their Orders and Order Details the query would look like,     //LINQ to SQL way… Read more

LINQ to SQL : Update data through Object Model

LINQ to SQL support updating data through object. Continuing with my previous blog on INSERT, let me discuss about the update method   static void Main(string[] args) {     string strConnection = @”Connection String”;       TestDB db = new TestDB(strConnection);         //Here I am finding the employee with Id 19     var updateQ… Read more

LINQ to XML : Join Xml Data

Let’s say I have created two Xml files using LINQ to XML from Northwind database. I have taken two tables Category and Products and tried to join between two different files.   Category XML   <?xml version=“1.0“ encoding=“utf-8“?> <categories>   <category id=“1“>     <CategoryName>Beverages</CategoryName>   </category>   <category id=“2“>     <CategoryName>Condiments</CategoryName>   </category>   <category… Read more

Setup and Deployment : Custom Action to Capture User Input

Purpose Users are allowed to pass Product Key while installing in .msi. During that we want to capture it for registration to avoid piracy. Challenges When we use “Customer Information” dialog in “Start” action, it has “SerialNumberTemplate”. But capturing information from there is really tough as mentioned in the article http://support.microsoft.com/kb/253683/en-us. So we have to… Read more

LINQ to SQL : Returning Scalar Value from Stored Procedure

In LINQ to SQL it is not that easy thing to achieve as compared to other features. Let us assume you have a Stored Procedure like, Case 1: With Output Parameter CREATE PROCEDURE [dbo].[GetEmployeeCount]       @OutVal DateTime OUTPUT AS BEGIN       SELECT @OutVal = GetDate() END You need to write code which will look like,… Read more

Choosing between ADO.NET Entity Framework and LINQ to SQL

As part of my day to job I come across a very common question from the developer community that one should be using LINQ to SQL (L2S) or ADO.NET Entity Framework (EF).   Earlier I have posted a blog containing the features http://blogs.msdn.com/wriju/archive/2009/01/05/choosing-between-linq-to-sql-and-entity-framework.aspx.    To me I feel very excited about EF as it has got… Read more

LINQ to SQL : Paging Data

When we work with relational database and especially when with larger data we generally go for custom paging. This allows us to create superfast application.   The simple logic for paged query is like,   Let’s suppose you have 100 rows. Now you want to get data of page size 10 for page 2.  … Read more

LINQ to XML : Changing connectionString in app.config

When you create data bind application using wizard in Windows Forms application and connection string gets added to you settings file. Now you may be interested in changing that connection string but problems, 1)     The connection string in settings has an Application Scope so it is ReadOnly property. You modify and remove “ReadOnly” from .vb… Read more

LINQ to SQL Windows Form Binding Data Step by Step

LINQ to SQL designer in Visual Studio allows us to create mapped class using the drag and drop feature from Server Explorer. Now that is business object which ideally you could use as your datasource and from Visual Studio 2008. So let us have this step by step, Open your Visual Studio 2008 and create… Read more

ADO.NET : OleDbCommand Parameterized Query Sequence Rule

While working with MS Access database with OleDbCommand you might have faced issue that your parameterized update statement is not working. The most frustrating part is that it also does not throw any runtime error. So ideally you paralyzedJ.   Golden rule is that you need to maintain the exact sequence of parameters you have… Read more

Windows Forms – Enable Shortcut Key all over the Form

Windows Application and shortcut key are synonyms. People prefer to use shortcut keys for faster activity. Assume you are in a text box and you want to hit F5 to reload the form. You do not want to move your mouse cursor. So what you will be doing is that you will be adding “Key… Read more

Windows Phone 7 – Binding Data to ListBox through Code

In Windows Phone 7 we need to display data programmatically. Below one demonstrates the simply way of binding data through code. Suppose you have Emp class as below. public class Emp { public int Id { get; set; } public string Name { get; set; } } Let’s create List<Emp> List<Emp> myData = new List<Emp>()… Read more

C# 3.0 : Exploring Lambda Expression

I started playing with Lambda expression after the TechEd demo by Anders Hejlsberg. Couple of nice things I would like to share with you.   As there might be many definitions for Lambda expression but to me Lambda Expression is the concise way to write functional implementation for Anonymous Method. This is been used by… Read more

LINQ: Query to SQL, XML and Object and JOIN them

Getting data from SQL, XML and Object and joining them using Language Integrated Query is something you might be looking for. I have created a small application which brings data from SQL Server (table name is Employee), XML (file name is Department.xml) and Object (Generic list containing list of Managers).   My SQL Table Looks… Read more

LINQ to SQL : Caching the query execution

LINQ to SQL executes or generated SQL statement only when you run a foreach statement or you perform to ToList() method to it. If you need to display the output multiple times without executing the real database query, you can store them in memory. This can be done only when you are sure that the… Read more

LINQ to XML : Creating complete XML document

LINQ to XML API allows us to create complete XML document as expected with all the elements. So this X-DOM has everything as you expect.   Simple sample looks like,     XDocument doc = new XDocument(     new XDeclaration(“1.0”, “utf-16”, “true”),     new XProcessingInstruction(“test”, “value”),     new XComment(“This is comment by you”),     new… Read more

ClickOnce Deployment : System.Deployment API

Applied to: Visual Studio 2005   ClickOnce is the deployment revolution for SmartClient applications. This is very cost effective solution for Smart Client applications. Support cost is very less and the deployment is per user basis. So user does not need Administrator right to install the application and security sandboxing is integral part to it…. Read more

VB.NET 9.0: XML Literal

This is the one feature which can make VB.NET developers feel better than C# folks. I have seen people complaining about MS saying that MS has done lot for C# but not equally for VB.NET. One of the biggest was Refractoring. There are so many such. But this feature is just “SPELLBOUND” when I first… Read more

Free EBooks at CodePlex

There are many more books available. Go and grab them   ·         Acceptance Test Engineering Guidance ·         Application Architecture Guidance ·         Common Service Locator ·         Composite Application Guidance for WPF ·         Design for Operations ·         Enterprise Library ·         ESB Guidance ·         GAX Extensions Library ·         Guidance Explorer ·         Performance Testing Guidance for Web Applications ·        … Read more

LINQ to XML : Modifying XML document

You have XML document now you want to modify that XML file using LINQ to XML. It is as easy as you generally modify any database column value.   Let us create a dummy XML stream,   //Create dummy XML to work var root = new XElement(“parent”,     from i in new int[] { 1,… Read more

LINQ to SQL : Enabling .dbml file for WCF

LINQ to SQL is object relational model and .dbml file generates the class file for all kind of Create, read, update and delete (CRUD) through the mapping mechanism. Ideally this should allow us to enable it for WCF Service. But for that we have to manually add DataContract and DataMember attributes. We can use .dbml’s… Read more

C# 3.0 : Evaluation of Lambda Expression to Language INtegrated Query (LINQ)

From code name “cool” to C# 3.0, it’s been a long journey for this amazing language with .NET Runtime. Here I am going to show you the evaluation step by step.   Let us assume we have generic list of integers and I need to find the even numbers from that list,   List<int> arrInt… Read more

What do I have to do if I install IIS after Visual Studio

What happens if you install you Visual Studio then realize that you need IIS for you application to test and run. We often do this. I have seen people uninstalling Visual Studio and then installing it again after IIS to make sure ASP.NET works fine. Wow!! There is an easy way to do it, Open… Read more

LINQ: Query vs Lambda Expression

  LINQ is not just for the developers who used to write queries for databases but also for the Functional Programmers. So do not worry if you are not very comfortable with SQL kind of queries, we have a very nice option called “Lambda Expression”. Here I am going to demonstrate the scenario for both… Read more

Code First EF 4.1 : Building Many to Many Relationship

Since we do not have any designer question might arise how can we create Many to Many relationship in Code First 4.1. Here it is public class Emp { public Emp() { Projects = new HashSet<Project>(); } public int EmpId { get; set; } public string EmpName { get; set; } public ICollection<Project> Projects {… Read more

LINQ to SQL : Execution Architecture

In L2S query execution can be separated in two major areas. One is to fetching the data another is manipulating the data (update, delete and insert). I use one slide during my L2S demo and here it is,     Fetching data from database   LINQ is only from fetching the data from database. LINQ… Read more

Visual Studio 2008 : How to add Visualizer for LINQ

There are two very important visualizers for LINQ which are not part of default installation.   The visualizers are Ø       ExpressionTree Visualizer Ø       SqlServerQuery Visualizer     Both the visualizers are available from   Visual Basic Samples for Visual Studio 2008 Beta 2   Visual C# LINQ and language samples for Visual Studio 2008 Beta 2  … Read more

LINQ to XML : Working with Namespaces

If you are working with complex real world XML then you have to deal with namespaces to disambiguate. There are several ways to implement namespaces in LINQ to XML. One is you can use pure string to add your namespace with each element declaration, like   <root>   <child /> </root>   To create the… Read more

VB.NET 9.0: Object and Array Initializers

Last week I was exploring VB.NET for the ISV demo delivery. Some findings I want to share with you. First the object and Array Initializers   Let’s suppose we have a class called Customer   Public Class Customer     Public Id As Integer     Public Name As String End Class   Now when you initialize… Read more

LINQ to XML : Handling blank or no Element and Attribute

It quite so happen that you are working with XML where you are expecting a specific element in every set. But somehow that is missing in some of the sets. Now at runtime you would get an error.. The XML file which I am targeting <?xml version="1.0" encoding="utf-8"?> <Employees> <Employee Location="Earth"> <Name>Wriju</Name> <Email>a@a.com</Email> </Employee> <Employee… Read more

VB.NET 9.0: Lambda Expression

In VB.NET 9.0 Lambda is one of the features we have here. Lambda expression is just another way to call Anonymous method/delegate.   Let’s look into a generic list of integers, and play with it,   Dim arrInt As New List(Of Integer)   For i As Integer = 1 To 10     arrInt.Add(i) Next  … Read more

LINQ to SQL: Working with hierarchical data

LINQ to SQL supports hierarchical data and you can easily create a query and get output from there. Let us take an example of Northwind database. Northwind has Category -> Products -> Order_Details tables. -> indicates one to many relationships here. So ideally for a Category can have multiple products and a product can have… Read more

Closing a Windows Form by pressing ESC key

While I was developing one Windows Forms application, it was required for me to close the popup forms when user will press ESC key. I tried adding the Form’s KeyPress event. It was not working as expected. Then I thought I should write a code to find all the controls to my form and add… Read more

C# 3.0 : Useful keyword “var”

People complain about the keyword “var”. Especially, when we use it with the strict programming language like C# in .NET. Developers also complain about the readability part of it. I totally agree with them, but the scenarios where there will be no options but the “var” when it comes to on the fly projection of… Read more

LINQ to CSV : Getting data the way you want

Getting data from CSV is one of the mostly used business in applications/tools development. Here how we can do it in LINQ, You have a table called Emp with the below details, CREATE TABLE [dbo].[Emp](       [Id] [int] IDENTITY(1,1) NOT NULL,       [FirstName] [varchar](50) NOT NULL,       [LastName] [varchar](50) NULL,  CONSTRAINT [PK_Emp] PRIMARY KEY CLUSTERED… Read more

LINQ to SQL support inserting data through object.

LINQ to SQL support inserting data through object.   using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Linq;   namespace Linq2Sql_demo_doc {     /// <summary>     /// Class to represent the SQL Server table     /// Emp     /// Id int     /// Name varchar(50)     /// </summary>    ///     [Table(Name=“Emp”)]     public class… Read more

LINQ to SQL : Understanding Compiled Query

Understanding Compiled Query connects me to my experience in C# 3.0. Based on my personal understanding I am discussing it.   You may be aware of Func<>. And you know it is a flexible delegate which allows you create reusable functions. Exactly the same way we can create compiled query so that we can prevent… Read more

LINQ to XML : Adding Namespace quickly

I have written a post earlier on how to attach Namespaces. After reading my article someone complained about the redundancy of the code. I also realized the pain. I was reading the book C# 3.0 In a Nutshell. There I got a very elegant solution. Let me explain the scenario,   If you create a… Read more

Code First EF 4.1 : Missing “ADO.NET DbContext Generator” VS Template

I have seen people coming back to me asking questions about the template visible in Visual Studio 2010 as “ADO.NET DbContext Generator”. This template allows you to create the POCO classes and the context for CodeFirst from already existing edmx file. The template in Visual Studio looks like But missing. But why? At times if… Read more

XLinq: Beginners Walkthrough

  Let’s play with Linq to XML (aka XLinq). XLinq is different from conventional .NET way to work with XML. Linq to XML is not the replacement it is smarter and superior way to work with XML with Language-INtegrated Query.   Let’s suppose you need to create XML content like   <employees>   <employee age=“28“>… Read more

Orcas March 2007 CTP VPC and its Base Image

We have released the VPC of Orcas March 2007 CTP to avoid the conflict in production machine. Since the Virtual PC 2004 SP1 is free and now downloadable from MSDN. One very important thing is that you should not miss to download the Orcas Base Image. If you miss to download this you will end… Read more

LINQ to SQL : Understanding Mapping

In LINQ to SQL you play with pure .NET objects and write your LINQ on top of that. But question might arise how this magic happens. Though we say that it is object, the question might arise in our mind that there has to be a mechanism through which it connects. Yes, there is. That… Read more

Installing TFS 2010 is very very Easy

Installing Team Foundation Server 2010 is as easy as Microsoft Office Installation. This is my second attempt to install single server TFS 2010. I am successful again. Few things we need to take care is 1. Use the Team Foundation Server 2010 Installation Guide and follow it step by step at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2d531219-2c39-4c69-88ef-f5ae6ac18c9f&displaylang=en 2. I had… Read more

LINQ to XML : Working with Prefixes

Based on my previous post on LINQ to XML : Working with Namespaces, if you want to add prefixes to your Xml things becomes little crazy. The trick is that you have to use XAttribute() to attach prefixes. So the Xml as below need the following code,     <pfx:root xmlns:pfx=“urn:mynamespace-com“>   <pfx:child /> </pfx:root>… Read more

LINQ: OfType<T> Query Operator

    LINQ comes with the OfType<T> query operator, through which we can filter the required object type from a heterogeneous array.   Suppose below is the scenario where we have array with various types but will only retrieve the string type. Here we go with ease of life,     using System; using System.Collections.Generic;… Read more

Windows Phone 7.5 : Working with Azure Storage Table

If you have Windows Azure Table Storage and you want to access that from your phone then the best one to me to use the proxy or OData. Because then you will be able to control the number of rows as Phone has limited capacity and Azure Table Storage is massive. However, you can directly… Read more

LINQ to XML : Two important classes XElement and XAttribute

XElement and XAttribute are the two  very important classes available in System.Xml.Linq.dll assembly. Using these two classes you can do lot of things in the LINQ to XML world. I will show you step by step how,   For just an element   XElement _root = new XElement(“root”);   _root.Save(fileName);   And the output will… Read more

LINQ to SQL : New method DataContext.GetCommand()

LINQ to SQL we can read the generated T_SQL query using DataContext.Log or SQLQueryVisualizer. But If you are working with WebProject the Log property not very much convenient as you have to use TextWriter to dump the generated T-SQL query.   In Orcas Beta 1 we had DataContext.GetQueryText which used to give us the generated… Read more

LINQ to Entity : Supported and Unsupported Methods

There is a correction for this Post, so do I have changed the title. Thanks to Chris Love who pointed me the faults with earlier post, I got few question on some of the popular paging methods of LINQ which does not work on LINQ to Entity. This is by design and quite logical. In… Read more

Sharing “var” across the method

One of the biggest limitation in “var” is that it cannot be shared across the methods. So if you are doing something using that keyword then you have to stick to the local. I was reading Alex’s Blog where he explained it very nicely,   Here is my implementation,   Create an Extension method  … Read more

Celebrating my 100 posts!!!

Thanks to everyone who supported me in this BLOGGING journey. I started blogging back in May 2006, was not very regular blogger till September 2006. I blog to share my .NET adventure, starting from C# 2005 to LINQ (C# 3.0). I use them to convey the interest for others.   In Microsoft I work for… Read more

Windows Store App displaying Data in two more columns in ListView

Windows Store apps comes with some amazing data bound controls. The most favorite among them is ListView and GridView. The ListView shows data in vertical scrolling mode and GridView shows data in horizontal scrolling. My pal was building an app where she needs to display data in two columns while having the vertical scrolling enabled…. Read more

Windows Phone 7 : Building Simple RSS Reader

Here we will build simple RSS reader in Windows Phone. Reading RSS is reading XML file online. So you need some engineering between XML and XAML. Here you go. Your phone UI <Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″> <ListBox Name=”lstRSS”> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=”{Binding Path=Title}”></TextBlock> <TextBlock Text=”{Binding Path=PubDate}”></TextBlock> <TextBlock Text=” “></TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid>… Read more

TechEd 2011 India – Special

I have been following TechEds since 2005. This time India TechEd 2011 is very special to me. I am delivering session called Data Access Methodologies: When to choose what (ADO.NET, Entity Framework, LINQ, WCF Data Services) and the official abstract says, Often an Application requires to access database. A lot of evolving data access technologies… Read more

LINQ to XML : Creating XML from another XML

Based on my previous post if I have to filter the list of customers only in the country “US” and create another XML which may look like,   <?xml version=“1.0“ encoding=“utf-8“?> <usaCustomers>   <usaCustomer>     <title>Marketing Manager</title>     <name>Howard Snyder</name>   </usaCustomer>   <usaCustomer>     <title>Sales Representative</title>     <name>Yoshi Latimer</name>   </usaCustomer>   <usaCustomer>    … Read more

Windows Phone 7 : Using Local Database for Application

Windows Phone uses concept of Local Database and by implementing LINQ to SQL you can create 100% relational database driven application. To understand more on this refer http://msdn.microsoft.com/en-us/library/hh202860(VS.92).aspx So what you need is the good old tie up between Silverlight and LINQ to SQL. Here we go. You need to refer System.Data.Linq assembly and use… Read more

Visual Studio 2008 Beta 2 is here

Choose the one you want Visual Studio 2008 Standard Edition Beta 2 Visual Studio 2008 Professional Edition Beta 2 Visual Studio Team System 2008 – Team Suite Beta 2 Visual Studio Team System 2008 – Team Foundation Server Beta 2 Visual Studio Team System 2008 – Test Load Agent Beta 2 MSDN Library for Visual… Read more

LINQ : IEnumerable<T> and IQueryable<T>

IEnumerable<T> and IQueryable<T> are the two most used terms of any LINQ discussion. What I am trying to here is that I am trying to simplify the two interfaces depending on their behavior. In LINQ world we generally have few providers available within .NET Framework, like LINQ to Object, LINQ to SQL, LINQ to XML…. Read more

Visual Studio 2012 Menu in Small (disable ALL Capital)

My Visual Studio 2012 Menu looks like If you want to do it run this poweshell Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\11.0\General -Name SuppressUppercaseConversion -Type DWord -Value 1 Or change the registry HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General\SuppressUppercaseConversion That’s it!!! Happy weekend. Curtsey to this resource Namoskar!!!… Read more

LINQ to Entity : Querying data using ADO.NET Entity Framework

ADO.NET Entity Framework have evolved since we have released it first time. Now with the Visual Studio 2008 if you install the .NET Framework 3.5 SP1 and Visual Studio 2008 SP1 you will get the fully functional version of ADO.NET Entity Framework. This is post Beta 3 release. To create a .edmx file you have… Read more

LINQ to SQL : Using ChangeSet for Audit Trail

Most of the transactional scenario, you may need to add the transaction to some table for ref. many apps does it for admin perspective.   Problem   You can do it in LINQ to SQL with ChangeSet but the problem is with Inserts. It does not give you the Identity field value until and unless… Read more

LINQ to XML : Querying XML with Namespaces

This question arises in one of discussions. If you have a XML document with “xmlns” then LINQ to XML does not return any IEnumerable<T> J. This is strange but true for XPath and XQuery. There is a trick to get it done, Let us assume that you have a XML as follows, <?xml version=“1.0“ encoding=“utf-8“?>… Read more

Visual Studio 2012 Solution Explorer Enhancements

Visual Studio 2012 comes with a lot of enhancements. One of the significant one is the Solution Explorer enhancement and it has many. Solution Explorer looks like a build from scratch. The new Solution Explorer is the combination of Object Browser, Class View, Find All References etc. Ideally you do not need to go to… Read more

Repository Pattern with ADO.NET Entity Framework Hack

Let’s build ADO.NET Entity Framework library using Repository Pattern. There are a many ways but this is probably the easiest hack.  First build a blank solution Then add a class library called “DAL” and add a class called “Employee” namespace DAL { public class Employee { public int Id { get; set; } public string… Read more

C# 3.0 Enhancements: Extension Methods

Extension Methods are different way of implementing static method. In C# 3.0 it allows us to extend any type and add method for that type. While writing extension method you need to Ø       declare a public static method Ø       the first parameter of that method should be the type of the object Ø       “this” keyword… Read more

ADO.NET Entity Framework : Working with Stored Procedure

Here we go, I generally get questions from developers that if they will have to scrub the existing powerful stored procedure they have written by investing time and money. The answer to that is “NO”. You must enjoy using it as it has its own power.   So it is very simple in ADO.NET Entity… Read more

Welcome to the World of Windows Azure

I am very much excited as I should be to start with my First Windows Azure Application. I did install the Azure related bits in my machine and got the token for uploading my test application. Then with the passion cherished by created the application which I am running at http://wriju.cloudapp.net, so let us enjoy…. Read more

Available Windows Phone 8 MSDN Webcast Recording

We have recently done the webcast series for Windows Phone 8. Below are the recordings Getting Started with Windows Phone 8 – Development Tools & Dev Center By Wriju Ghosh (@wriju_ghosh)  Recording https://msevents.microsoft.com/CUI/InviteOnly.aspx?EventID=64-1F-EB-FA-78-CA-3F-28-5D-88-10-51-3B-C7-AF-CF&Culture=en-IN&community=0  Designing Apps for Windows Phone 8 By Ujjwal Kumar  Recording https://msevents.microsoft.com/CUI/InviteOnly.aspx?EventID=64-1F-EB-FA-78-CA-3F-28-AE-2A-11-0B-C5-33-91-0C&Culture=en-IN&community=0  Application Lifecycle for Windows Phone 8 By Ujjwal Kumar Recording https://msevents.microsoft.com/CUI/InviteOnly.aspx?EventID=89-38-23-13-41-AF-5B-81-DA-18-FA-29-08-7A-89-AA&Culture=en-IN&community=0 … Read more

Code First 4.1 : Using Stored Procedure to Insert Data

Code First in Entity Framework does not support Stored Procedure by default. As there is no designer we cannot even map our stored procs to the entity. There are a many scenario we have seen where we are bound to use stored procedure for any database modifications (insert/update/delete). Here is how we can use stored… Read more

WinJS.xhr Issue while running next time

Windows 8 and WinJS.xhr goes hand in hand while developing application to consume web. I was trying out something like that. It used to work fine for the first run. But the second and consecutive runs it gives error as below. Error message Exception is about to be caught by JavaScript library code at line… Read more

Windows Phone 7 : IsolatedStorage Save and Read Data to a File

Windows Phone 7 apps runs in an isolated environment and often application needs store and retrieve data from files. Application can use its IsolatedStorage to store and retrieve data. The example shows how to read from a  file and display it in ListBox and save data to the file located in its isolated storage. We… Read more

C# 3.0 : Joining two in-memory collection through LINQ

LINQ allows us to join different collection source provided we are mapping with two properties with the same type. It is easy, it is quick and it is concise.     //Create Employee Class class Employee {     public int ID { get; set; }     public string Name { get; set; }     public… Read more

C# 3.0 Enhancements: Collection Initializers

In C# 3.0 we can easily initialize collection. It is smarter and concise way of writing code.   There are couple of things we should consider while initializing the collection. Ø       The collection should implement ICollection<T> Ø       The collection should have a provision to invoke ICollection<T>.Add(T)     Here is couple of them. I am… Read more

ADO.NET Entity: LINQ to Entity with Relationship

Relationship and getting data from Entity Framework using Northwind database Simple Query   using (NorthwindEntities ctx = new NorthwindEntities()) {     var query = from o in ctx.Orders                 select o.OrderID;       foreach (var k in query)     {         Console.WriteLine(k);     } }   Now if you want to filter this with the… Read more

LINQ to SQL : What is DataContext.Translate Method

DataContext’s Translate method converts existing IDataReader to an IEnumerable<T>. This is very useful when you may need to run raw SQL Query though System.Data.Linq. I am getting few similarities with DataContext’s ExecuteQuery.   How Translate works +++++++++++++ Assuming I am using Northwind database.     using (NWDataContext db = new NWDataContext()) {     DbConnection conn… Read more

C# 3.0 Features: Automatic Property (Part 2)

Thank you everyone for showing interest on my blog entry C# 3.0 Features: Automatic Property. Questions like, why this approach? What if there is any condition in property? Let me tell you, we have implemented the higher level of abstraction in C# 3.0. If you are simply creating a property (we often do) then the… Read more

C# 4.0 : Co-variance and Contra-variance

Here I am going to talk about the feature called Covariance and Contravariance. To show you the example I will use delegate. Now what is it? This would be a big question and with no hesitance I must say that you should visit Eric’s blog. There are some articles which will help you understand. To… Read more

Is my PC can install Windows Phone 8 SDK and Emulator

Most PC can run Windows Phone 8 SDK but Emulator will not be installed properly if the below specification is not available Download CoreInfo from http://technet.microsoft.com/en-us/sysinternals/cc835722 Run "coreinfo -v" in command If * is there after EPT Good – is there after EPT Will not work Good Is not ready Namoskar!!!… Read more

XLinq: Create XML from object using LINQ

  We have seen how to create the XML content from raw data initializing elements and attributes one by one. More realistic approach in the world of application development would be to read the values either from relational database or collection. Let’s use the combined power of LINQ and XLinq to create XML content easily… Read more