Skip to main content

Posts

Showing posts from February, 2011

LinQ Database Update Operations In C#

Recently, I have discussed about getting started linq to sql in c#.net. That articles also covered for creating select query for retrieving both single and multiple results. Today, in this tutorial, I will try to give some more examples on other types of database operations, that writes/updates the database. These will cover writing and executing 'Update'/'Insert'/'Delete' query in the proper way. Please use the database structure given below, if you want to try the following examples directly. I am assuming, you already know how to create dbml/linq to sql classes: Example DBML To be used In this tutorial Insert Data With Linq: Being LinQ as an ORM, its quite easy and sql syntax free way to insert data using LinQ. We just need to create a new object of corresponding database table type, then add it to the DataContext object and then commit the changes. Here is a small block of c# code samples to create new 'User' linq to sql class(Representin...

Beginning LinQ To SQL In C#.NET

In this tutorial, I will discuss about basic linq to sql overview, then how to get started very quickly with its usage on our C#.NET based applications(This can be used in both desktop and web applications in the exactly same way). Besides, I will also discuss about using 'select' query in linq to retrieve data and also traverse through the query results(in case of multiple result objects). To understand this tutorial properly, You should have handy knowledge on c# and also have visual studio 2008+(.NET Framework 3.0+ ) to successfully able to run LINQ To SQL examples . What Is LINQ To SQL? Full meaning of LINQ is ' L anguage In tegrated Q uery', which replaces the traditional sql query execution process. Moreover, it doesn't only applicable to manipulate database results, but it can also be used to manipulates array/list collections. LinQ was released as part of the .NET framework 3.0 and can be used from languages supported by .NET framework like C#, V...

LINQ to SQL and Visual Studio 2008

Introduction LINQ is one of the hottest buzz words out there today. LINQ is the new query language that can query any collection-based mechanism, whether it's an enumerable collection, XML, or a database . LINQ uses a structure very similar to an ANSI SQL query, with the select statement at the bottom instead of the top. The purpose of this article isn't to discuss LINQ queries (although it will to a point), but to discuss LINQ to SQL capabilities in the Visual Studio 2008 designer. When looking at LINQ, pay attention to the System.Linq, System.Data.Linq, and the System.Xml.Linq namespaces for all of your data querying needs. The System.Data.Linq namespace has a lot of the core objects used with LINQ-to-SQL, and System.Linq has the extension methods and lambda expressions that make querying data even easier. Visual Studio 2008 Support I'm sure, unless you are new to .NET, that you are familiar with the code generation capabilities of .NET data storage mec...

LINQ To SQL Tutorial

Introduction With .NET Framework 3.5 Microsoft released Language Integrated Query aka LINQ. LINQ enables developers to query data sources using a query like syntax with both C# and VB.NET. These data sources can be collections, SQL Server databases, XML, DataSets etc. Other than what is supplied by Microsoft, LINQ is also extensible. This means that you can query data sources beyond what Microsoft ships. Examples of such implementations are LINQ To Flickr, LINQ To Amazon, LINQ to Google etc. In this article I will show you how you can use LINQ To SQL to perform CRUD operations on a SQL Server database. I will use Northwind database and build an ASP.NET application to demonstrated the capabilities of LINQ To SQL. You can download Northwind database here . Toolset for this article Visual Studio 2008 .NET Framework 3.5 (This is already installed if you have Visual Studio 2008) SQL Server 2005 (You can also work with SQL Server Express) Solution Structure For this article we will...

Using the WPF Toolkit DataGrid

WPF comes with a large number of built in controls, but from the beginning it has lacked something that many application developers find extremely important - a DataGrid. You can use the ListView to create something approximating a DataGrid (I've talked about it in a couple different tutorials), but it is a lot of work and not particularly straightforward. Thankfully, Microsoft realizes how important a full-featured DataGrid is - and how you probably don't want to wait for the next version of WPF to be able to use one. This is where the WPF Toolkit comes in. The WPF Toolkit is "a collection of WPF features and components that are being made available outside of the normal .NET Framework ship cycle" which to me translates as "handy new controls I don't have to wait for". The WPF Toolkit has a couple different controls, but the big one is the DataGrid - and that is what we will be exploring today. You can grab the toolkit from here . It...