Home /

| RSS

ADO.NET Data Services Logical Operators

In this post we will look at Logical Operators in ADO.NET Data Services. These operators can be used as filter expressions in our requests and ADO.NET Data Services applies the filter before results are returned. We will use Data Services generated over Adventureworks Lite database. If you are new to ADO.NET Data Services and would [...]

[ More ] August 26th, 2009 | No Comments | Posted in Programming |

Execute Stored Procedure With ADO.NET Data Services

Introduction
In an earlier article I looked at how DO.NET Data Services can be used with ASP.NET. In this post I will talk about using ADO.NET Data Services to retrieve data via SQL Server stored procedure. Doing this is simple and I will follow a similar approach to hook everything up as I did in my [...]

[ More ] August 16th, 2009 | 7 Comments | Posted in Programming |

ADO.NET Data Services With ASP.NET

Introduction
In this tutorial we will look at how ADO.NET Data Services can be used to create services which are consumed by ASP.NET client. We will use Adventure works Lite database as an example to demonstrate the concepts. Code for this article can be downloaded at the bottom of the article.
ADO.NET Data Services as the name [...]

[ More ] July 28th, 2009 | 12 Comments | Posted in Programming |

Insert Master Detail Data With LINQ To SQL

Best thing about running One .Net Way is interaction with members of developer community. I thoroughly enjoy answering questions which come my way through this site. Early in the morning today I saw a question by Joey. To avoid loosing details in paraphrasing, here is the exact question asked by Joey.
I’m new to LINQ. If [...]

[ More ] July 8th, 2009 | 8 Comments | Posted in Programming |

Select Max Value With LINQ To SQL

Today I was asked a question by a developer on my team. The question is “How do you select MAX value for a column in a table with LINQ To SQL?”. I will try to answer the question in this post with an example. Let’s say that we want to retrieve maximum unit price from [...]

[ More ] July 7th, 2009 | 2 Comments | Posted in Programming |

Create T-SQL CASE Statements With LINQ To SQL

I was recently helping Nosh with a LINQ To SQL query where he wanted the resulting T-SQL query to have CASE statements. Having CASE statements in T-SQL queries is a common scenario but how do we it in LINQ To SQL .After some investigation I found the solution which I am presenting here using an [...]

[ More ] March 24th, 2009 | 1 Comment | Posted in Programming |

Get Last Row From Table Using LINQ To SQL

This query returns the last row from Sales.Customer table in Adventure Works database. I am using LINQPad to write and execute my query.
(from c in Customers
select c)
.OrderByDescending(x=> x.CustomerID).First()
 
Here is the result as displayed in LINQPad
 

[ More ] March 9th, 2009 | No Comments | Posted in Code Snippets |

LINQ Equivalent Of Where IN With Int

Earlier I wrote a post showing how to write a LINQ query which gets transformed into a T-SQL query with a "Where In" clause. I had a comment on the post by Steve saying that the approach only works with strings. In this post I will show you a similar query which works with Integers.
Let’s [...]

[ More ] January 5th, 2009 | No Comments | Posted in Programming |

LINQPad with Intellisense

I had a look at LINQPad few months ago when I wrote about how you can use this tool to view generated LINQ To SQL Queries. There is not doubt that LINQPad comes in as a very handy tool when writing LINQ queries. But writing queries in LINQPad has not been that easy. Until Now!
LINQPad [...]

[ More ] December 23rd, 2008 | No Comments | Posted in Programming |

Remove Duplicate Lines From A Text File Using LINQ

A question was posted on c-sharpcorner forums asking how you would remove duplicate lines from a text file. It got me thinking about how this problem could be addressed using LINQ. Before I get into the solution, here is the problem statement.
The problem
I am trying to remove duplicate lines from a text file. To [...]

[ More ] December 12th, 2008 | 1 Comment | Posted in Programming |

Dynamic Sort With LINQ To SQL

Sometime ago I wrote a post showing how to do dynamic sort with LINQ. That approach worked well with LINQ To Objects. Today I spotted a question on the forums where Levi asked a question about doing dynamic sorts with LINQ To SQL. My earlier approach will work once all the data is retrieved on [...]

[ More ] November 19th, 2008 | 9 Comments | Posted in Programming |

Enum Support With LINQ To SQL And SqlMetal

As a programmer I love my enums. I find code written using enums to be more readable than without them. However, there has been and there still is a disconnect between lookup tables in a database and enums in code. One has to restore to some creative trickery to get them working in harmony. Recently [...]

[ More ] November 18th, 2008 | 2 Comments | Posted in Programming |