Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Performance comparisons LinQ to SQL,ADO,C#

, 25 May 2008 CPOL
To compare existing approaches of accessing data (arrays,tables etc) with the new ones release with c#3.0 and LinQ.
source_file_and_sample_application.zip
Source File and Sample Application
Data
RetrieveUsingADO
RetrieveUsingADO
bin
Debug
RetrieveUsingADO.exe
RetrieveUsingADO.pdb
RetrieveUsingADO.vshost.exe
RetrieveUsingADO.vshost.exe.manifest
Release
RetrieveUsingADO.exe
RetrieveUsingADO.pdb
RetrieveUsingADO.vshost.exe
RetrieveUsingADO.vshost.exe.manifest
obj
Debug
RetrieveUsingADO.exe
RetrieveUsingADO.pdb
TempPE
Release
RetrieveUsingADO.exe
RetrieveUsingADO.pdb
TempPE
Properties
RetrieveUsingADO.suo
RetriveUsingLinQ
RetriveUsingLinQ
bin
Debug
RetriveUsingLinQ.exe
RetriveUsingLinQ.pdb
RetriveUsingLinQ.vshost.exe
RetriveUsingLinQ.vshost.exe.manifest
Release
RetriveUsingLinQ.exe
RetriveUsingLinQ.pdb
RetriveUsingLinQ.vshost.exe
RetriveUsingLinQ.vshost.exe.manifest
obj
Debug
Interop.Microsoft.Office.Core.dll
RetriveUsingLinQ.csproj.ResolveComReference.cache
RetriveUsingLinQ.exe
RetriveUsingLinQ.pdb
TempPE
RetriveUsingLinQfromSQL.designer.cs.dll
Release
Interop.Microsoft.Office.Core.dll
RetriveUsingLinQ.csproj.ResolveComReference.cache
RetriveUsingLinQ.exe
RetriveUsingLinQ.pdb
TempPE
RetriveUsingLinQfromSQL.designer.cs.dll
Properties
Settings.settings
RetriveUsingLinQ.suo
RetriveUsingLinQfromSQL.dbml
RetriveUsingLinQfromSQL.dbml.layout
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace RetriveUsingLinQ
{
	using System.Data.Linq;
	using System.Data.Linq.Mapping;
	using System.Data;
	using System.Collections.Generic;
	using System.Reflection;
	using System.Linq;
	using System.Linq.Expressions;
	using System.ComponentModel;
	using System;
	
	
	[System.Data.Linq.Mapping.DatabaseAttribute(Name="AdventureWorks")]
	public partial class RetriveUsingLinQfromSQLDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertCustomer(Customer instance);
    partial void UpdateCustomer(Customer instance);
    partial void DeleteCustomer(Customer instance);
    #endregion
		
		public RetriveUsingLinQfromSQLDataContext() : 
				base(global::RetriveUsingLinQ.Properties.Settings.Default.AdventureWorksConnectionString, mappingSource)
		{
			OnCreated();
		}
		
		public RetriveUsingLinQfromSQLDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public RetriveUsingLinQfromSQLDataContext(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public RetriveUsingLinQfromSQLDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public RetriveUsingLinQfromSQLDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<Customer> Customers
		{
			get
			{
				return this.GetTable<Customer>();
			}
		}
		
		[Function(Name="Sales.uspInsertIntoCustomer")]
		public int uspInsertIntoCustomer()
		{
			IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));
			return ((int)(result.ReturnValue));
		}
	}
	
	[Table(Name="Sales.Customer")]
	public partial class Customer : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _CustomerID;
		
		private System.Nullable<int> _TerritoryID;
		
		private string _AccountNumber;
		
		private char _CustomerType;
		
		private System.Guid _rowguid;
		
		private System.DateTime _ModifiedDate;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnCustomerIDChanging(int value);
    partial void OnCustomerIDChanged();
    partial void OnTerritoryIDChanging(System.Nullable<int> value);
    partial void OnTerritoryIDChanged();
    partial void OnAccountNumberChanging(string value);
    partial void OnAccountNumberChanged();
    partial void OnCustomerTypeChanging(char value);
    partial void OnCustomerTypeChanged();
    partial void OnrowguidChanging(System.Guid value);
    partial void OnrowguidChanged();
    partial void OnModifiedDateChanging(System.DateTime value);
    partial void OnModifiedDateChanged();
    #endregion
		
		public Customer()
		{
			OnCreated();
		}
		
		[Column(Storage="_CustomerID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int CustomerID
		{
			get
			{
				return this._CustomerID;
			}
			set
			{
				if ((this._CustomerID != value))
				{
					this.OnCustomerIDChanging(value);
					this.SendPropertyChanging();
					this._CustomerID = value;
					this.SendPropertyChanged("CustomerID");
					this.OnCustomerIDChanged();
				}
			}
		}
		
		[Column(Storage="_TerritoryID", DbType="Int")]
		public System.Nullable<int> TerritoryID
		{
			get
			{
				return this._TerritoryID;
			}
			set
			{
				if ((this._TerritoryID != value))
				{
					this.OnTerritoryIDChanging(value);
					this.SendPropertyChanging();
					this._TerritoryID = value;
					this.SendPropertyChanged("TerritoryID");
					this.OnTerritoryIDChanged();
				}
			}
		}
		
		[Column(Storage="_AccountNumber", AutoSync=AutoSync.Always, DbType="VarChar(10) NOT NULL", CanBeNull=false, IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]
		public string AccountNumber
		{
			get
			{
				return this._AccountNumber;
			}
			set
			{
				if ((this._AccountNumber != value))
				{
					this.OnAccountNumberChanging(value);
					this.SendPropertyChanging();
					this._AccountNumber = value;
					this.SendPropertyChanged("AccountNumber");
					this.OnAccountNumberChanged();
				}
			}
		}
		
		[Column(Storage="_CustomerType", DbType="NChar(1) NOT NULL")]
		public char CustomerType
		{
			get
			{
				return this._CustomerType;
			}
			set
			{
				if ((this._CustomerType != value))
				{
					this.OnCustomerTypeChanging(value);
					this.SendPropertyChanging();
					this._CustomerType = value;
					this.SendPropertyChanged("CustomerType");
					this.OnCustomerTypeChanged();
				}
			}
		}
		
		[Column(Storage="_rowguid", DbType="UniqueIdentifier NOT NULL")]
		public System.Guid rowguid
		{
			get
			{
				return this._rowguid;
			}
			set
			{
				if ((this._rowguid != value))
				{
					this.OnrowguidChanging(value);
					this.SendPropertyChanging();
					this._rowguid = value;
					this.SendPropertyChanged("rowguid");
					this.OnrowguidChanged();
				}
			}
		}
		
		[Column(Storage="_ModifiedDate", DbType="DateTime NOT NULL")]
		public System.DateTime ModifiedDate
		{
			get
			{
				return this._ModifiedDate;
			}
			set
			{
				if ((this._ModifiedDate != value))
				{
					this.OnModifiedDateChanging(value);
					this.SendPropertyChanging();
					this._ModifiedDate = value;
					this.SendPropertyChanged("ModifiedDate");
					this.OnModifiedDateChanged();
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
#pragma warning restore 1591

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

KshitijPandey

Unknown
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 26 May 2008
Article Copyright 2008 by KshitijPandey
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid