Click here to Skip to main content
15,896,201 members
Articles / Web Development / ASP.NET

Enterprise Application Architecture with LINQ to SQL

Rate me:
Please Sign up or sign in to vote.
4.73/5 (44 votes)
17 Oct 200722 min read 295.2K   4.1K   277  
A discussion about architectural patterns for using LINQ to SQL in enterprise applications, along with performance implications
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomerDetails1.aspx.cs" Inherits="CustomerDetails1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
	<style type="text/css">

.style1 {
	color: #333333;
}
</style>
</head>
<body>
    <form id="form1" runat="server">
    	
    	<asp:FormView ID="fvCust" runat="server" CellPadding="4" 
    	 DataSourceID="CustomerDS"
		 ForeColor="#333333" 
		>
			<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
			<editrowstyle backcolor="#2461BF" />
			<edititemtemplate>
				Address:
				<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
				<br />ContactTitle:
				<asp:TextBox ID="ContactTitleTextBox" runat="server" 
				Text='<%# Bind("ContactTitle") %>' />
				<br />Phone:
				<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' />
				<br />Fax:
				<asp:TextBox ID="FaxTextBox" runat="server" Text='<%# Bind("Fax") %>' />
				<br />Country:
				<asp:TextBox ID="CountryTextBox" runat="server" Text='<%# Bind("Country") %>' />
				<br />PostalCode:
				<asp:TextBox ID="PostalCodeTextBox" runat="server" 
				Text='<%# Bind("PostalCode") %>' />
				<br />City:
				<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
				<br />CompanyName:
				<asp:TextBox ID="CompanyNameTextBox" runat="server" 
				Text='<%# Bind("CompanyName") %>' />
				<br />ContactName:
				<asp:TextBox ID="ContactNameTextBox" runat="server" 
				Text='<%# Bind("ContactName") %>' />
				<br />CustomerID:
				<asp:TextBox ID="CustomerIDTextBox" runat="server" 
				Text='<%# Bind("CustomerID") %>' />
				<br />
				<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
				CommandName="Update" Text="Update" />
				&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
				CausesValidation="False" CommandName="Cancel" Text="Cancel" />
			</edititemtemplate>
			<rowstyle backcolor="#EFF3FB" />
			<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center" />
			<insertitemtemplate>
				Address:
				<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
				<br />ContactTitle:
				<asp:TextBox ID="ContactTitleTextBox" runat="server" 
				Text='<%# Bind("ContactTitle") %>' />
				<br />Phone:
				<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' />
				<br />Fax:
				<asp:TextBox ID="FaxTextBox" runat="server" Text='<%# Bind("Fax") %>' />
				<br />Country:
				<asp:TextBox ID="CountryTextBox" runat="server" Text='<%# Bind("Country") %>' />
				<br />PostalCode:
				<asp:TextBox ID="PostalCodeTextBox" runat="server" 
				Text='<%# Bind("PostalCode") %>' />
				<br />City:
				<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
				<br />CompanyName:
				<asp:TextBox ID="CompanyNameTextBox" runat="server" 
				Text='<%# Bind("CompanyName") %>' />
				<br />ContactName:
				<asp:TextBox ID="ContactNameTextBox" runat="server" 
				Text='<%# Bind("ContactName") %>' />
				<br />CustomerID:
				<asp:TextBox ID="CustomerIDTextBox" runat="server" 
				Text='<%# Bind("CustomerID") %>' />
				<br />
				<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
				CommandName="Insert" Text="Insert" />
				&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
				CausesValidation="False" CommandName="Cancel" Text="Cancel" />
			</insertitemtemplate>
			<itemtemplate>
				Address:
				<asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
				<br />ContactTitle:
				<asp:Label ID="ContactTitleLabel" runat="server" 
				Text='<%# Bind("ContactTitle") %>' />
				<br />Phone:
				<asp:Label ID="PhoneLabel" runat="server" Text='<%# Bind("Phone") %>' />
				<br />Fax:
				<asp:Label ID="FaxLabel" runat="server" Text='<%# Bind("Fax") %>' />
				<br />Country:
				<asp:Label ID="CountryLabel" runat="server" Text='<%# Bind("Country") %>' />
				<br />PostalCode:
				<asp:Label ID="PostalCodeLabel" runat="server" 
				Text='<%# Bind("PostalCode") %>' />
				<br />City:
				<asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>' />
				<br />CompanyName:
				<asp:Label ID="CompanyNameLabel" runat="server" 
				Text='<%# Bind("CompanyName") %>' />
				<br />ContactName:
				<asp:Label ID="ContactNameLabel" runat="server" 
				Text='<%# Bind("ContactName") %>' />
				<br />CustomerID:
				<asp:Label ID="CustomerIDLabel" runat="server" 
				Text='<%# Bind("CustomerID") %>' />
				<br />
				<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
				CommandName="Edit" Text="Edit" /> | 
				<a href="CustomerListing.aspx"><span class="style1">Back to CustomerListings</span></a>
			</itemtemplate>
			<headerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
		</asp:FormView>
    <div>
    <hr />
    	<asp:GridView ID="gvOrders" runat="server" CellPadding="4" ForeColor="#333333" 
		GridLines="Both">
			<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
			<rowstyle backcolor="#EFF3FB" />
			<editrowstyle backcolor="#2461BF" />
			<selectedrowstyle backcolor="#D1DDF1" font-bold="True" forecolor="#333333" />
			<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center" />
			<headerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
			<alternatingrowstyle backcolor="White" />
		</asp:GridView>
    
    </div>
			
			<asp:ObjectDataSource ID="CustomerDS" runat="server" 
			SelectMethod="GetCustomer"			  
			TypeName="Northwind.Business.CustomerBO" 
			DataObjectTypeName="Northwind.Data.DTO.Customer" UpdateMethod="UpdateCustomer"
			InsertMethod="InsertCustomer" 
			onobjectcreating="CustomerDS_ObjectCreating"
			>
				<selectparameters>
					<asp:querystringparameter DefaultValue="0" Name="id" QueryStringField="custid" 
					Type="String" />
				</selectparameters>
			</asp:ObjectDataSource>
    </form>
</body>
</html>

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I am a tech lead working for Cap Gemini. Although I primarily work with the Microsoft technology stack (including .NET and legacy technologies) I like to keep myself informed about developments in the Java world.

Comments and Discussions