background preloader

Using LINQ to SQL (Part 1)

Using LINQ to SQL (Part 1)
Over the last few months I wrote a series of blog posts that covered some of the new language features that are coming with the Visual Studio and .NET Framework "Orcas" release. Here are pointers to the posts in my series: The above language features help make querying data a first class programming concept. We call this overall querying programming model "LINQ" - which stands for .NET Language Integrated Query. Developers can use LINQ with any data source. LINQ supports a very rich extensibility model that facilitates the creation of very efficient domain-specific operators for data sources. What Is LINQ to SQL? LINQ to SQL is an O/RM (object relational mapping) implementation that ships in the .NET Framework "Orcas" release, and which allows you to model a relational database using .NET classes. LINQ to SQL fully supports transactions, views, and stored procedures. Modeling Databases Using LINQ to SQL: Understanding the DataContext Class LINQ to SQL Code Examples 5) Call a Stored Procedure

Walkthrough: Creating the Data Access and Business Logic Layers in ASP.NET When you work with data in ASP.NET, you will benefit by using common software patterns. One of these patterns is to separate the data-access code from the business-logic code that governs access to the data or that provides other business rules. In this pattern, these two layers are separate from the presentation layer, which consists of the pages that the Web site user accesses to view or change data. A Visual Studio Web site project with source code is available to accompany this topic: Download. The recommended approach is to separate the data access logic from the presentation layer. This separate layer is referred to as the data-access layer. If your Web site displays or updates data, you should create a data-access layer and business-logic layer before creating the user interface. A data-driven Web application usually includes a data-access layer by using typed datasets or entity classes that represent the data. Tasks illustrated in this walkthrough include the following:

LINQ to SQL (Part 6 - Retrieving Data Using Stored Procedures) Over the last few weeks I've been writing a series of blog posts that cover LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .NET Framework 3.5 release, and which enables you to model relational databases using .NET classes. You can use LINQ expressions to query the database with them, as well as update/insert/delete data. Below are the first five parts of my LINQ to SQL series: In these previous LINQ to SQL blog posts I demonstrated how you could use LINQ query expressions to programmatically retrieve data from a database. In today's blog post I'll cover how you can also use database stored procedures (SPROCs) and user defined functions (UDFs) with your LINQ to SQL data model. To SPROC or not to SPROC? The question of whether to use Dynamic SQL generated by an ORM or instead use Stored Procedures when building a data layer is a topic that generates endless (very passionate) debate amongst developers, architects and DBAs. Calling the SPROC in VB:

How N-Tier Architecture Application are made, using Stored Procedure in Database Layer Hi All,In this article i will be explaining how n-tier Architecture Applications are made. There are 3 Layers typical in any application. They are Presentation Layer: Presentation layer is basically the front end forms which is used by the end users Business Logic Layer: This layer consists of business logic like transactional operations Database Layer : Consists of data and data related programming like triggers, stored procedures & functions for complex sql transactions Making these three layers independent makes you the deal with these layers independently like any changes required in stored procedure logic can be done without disturbing other layers. Further application can be developed for other platform like from web to mobile application, without disturbing database layer and business logic layers To demonstrate i will be making small application using ASP.NET with C# & SQL server where add the State names in the database using a web form. download source code of above example

A simple 3-tier layers application in ASP.NET I will explain how to develop a simple application in ASP.NET using a three-tier architecture. The presentation tier The business tier The data tier Concepts: The presentation tier contains the UI (User Interface) elements of the site, and includes all the logic that manages the interaction between the visitor and the client’s business. The business tier receives requests from the presentation tier and returns a result to the presentation tier depending on the business logic it contains. The data tier is responsible for storing the application’s data and sending it to the business tier when requested. The first Step is to create a new Web Site - C# Language. We need to add a Master Page to define our web site style. Here is the design of our application. Creating the Database Script: Creating the Store Procedure Create Procedure GetClients AsSelect clientID,name,description From Client Adding Logic to the Site We need 3 classes Configuration GenericData Client Creating the Configuration Class

3-Tier Architecture in ASP.NET with C# Total Comments / Responses (44) Posted by: Raja on: 5/7/2008 This is very nice and simple article. Keep it up!!! Hi, Nice article; Well and simply explained. 1) Fix for the code block For the css 'pre', add new property 'min-width: 730px;' and add width nn percentage. just to give you flexibility to not show scroll bar for long screens. 2) Can you post other similar article with Ajax? I wonder if you can come up with the same but using Ajax Tabs. Tab Container (Container to hold GV, Add, Edit) First Tab Panel ... Why? Why? Mattberseth.com has good UI examples. But would like to see if you can come up with Tabs and your example above. Regards, Sreedhar Thanks Vansree for your suggestions. 1. Thanks and take care. Hi Haneef, In this case use my another article on 4-Tier architecture Thanks Hi Sir, IF in Insert method of DAL I have out parameter, how to access it in presentation layer Pushpalata, Read following article to know how to use output parameter

Implementing Business Logic (LINQ to SQL) The term "business logic" in this topic refers to any custom rules or validation tests that you apply to data before it is inserted, updated or deleted from the database. Business logic is also sometimes referred to as "business rules" or "domain logic." In n-tier applications it is typically designed as a logical layer so that it can be modified independently of the presentation layer or data access layer. The business logic can be as simple as a schema validation to make sure that the type of the field is compatible with the type of the table column. When you generate an entity class at design time, either manually or by using the Object Relational Designer or SQLMetal, it is defined as a partial class. In the implementing definition that you write in your separate code file, you can perform whatever custom logic is required. The following example shows part of the code generated by the Object Relational Designer for the DataContext class that has two tables: Customers and Orders.

3-Tier Architecture in asp.net using c# In this asp.net tutorial you will learn how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it n-tier architecture. Layer architectures are essentially objects and work in object oriented environment just like asp.net. 3-tier architecture is a very well known architecture in the world of software development, it doesn't matter whether you are developing web based application or desktop based, it is the best architecture to use. 3-Tier architecture consists of1) UI or Presentation Layer2) Business Access Layer or Business Logic Layer3) Data Access Layer Presentation LayerPresentation layer consists of pages like .aspx or desktop based form where data is presented to users or getting input from users.Business Logic layer or Business Access LayerBusiness logic layer contains all of the business logic. The figure clearly describe about the purpose of BAL and DAL. DbAccess.cs

Introduction: Planning an ASP.NET Web Site Before you create a Web site, it is always helpful to plan the site before you begin creating pages and writing code. Planning the site in advance can make it easier to create the overall look of the site and of site navigation. The size of a Web site can often determine the amount of planning you must do. A small, brochure-type Web site that just provides static information can be a relatively basic site that requires little planning. A Web site that accesses a data store, authenticates users, and that has localization and accessibility constraints can require more planning. The following topics cover information that pertains to the Web site as a whole, which includes information on the following: The type of Web site that you select.How you navigate through the site.Ways to create a consistent look and layout for all the pages in the site.How to access data from a data store. There are two project types you can create in Visual Studio 2008. HTTP is a stateless protocol. Accessibility

Walkthrough: Creating the Data Access and Business Logic Layers in ASP.NET When you work with data in ASP.NET, you will benefit by using common software patterns. One of these patterns is to separate the data-access code from the business-logic code that governs access to the data or that provides other business rules. In this pattern, these two layers are separate from the presentation layer, which consists of the pages that the Web site user accesses to view or change data. The recommended approach is to separate the data access logic from the presentation layer. If your Web site displays or updates data, you should create a data-access layer and business-logic layer before creating the user interface. A data-driven Web application usually includes a data-access layer by using typed datasets or entity classes that represent the data. The data-access layer includes all the code that is specific to the underlying data source. Tasks illustrated in this walkthrough include the following: For this walkthrough you will create a new database for tracking task items.

Related: