Preparation of the implementation of your first Yukon CLR (common language runtime) storage process
Preparation of the implementation of your first Yukon CLR (common language runtime) storage process
Author: Suhil Srinivas
Translation: Zhu 2
Original Source: http://www.c-sharpcorner.com/Longhorn/Yukon/First-CLR-Procedure.asp
Description
This article describes the preparation and implementation of a variety of Yukon CLR common language run-time storage process steps. On the development of mixed data types of SQL stored procedures, this is a starting point.
Demand
The correct installation of SQL Server Yukon beta1
Introduction
Yukon is Microsoft's latest version of SQL Server, which is one of the most important characteristics of it and. NET integration. More information on the Yukon, see Yukon FAQ. A use. NET compatible language prepared by the SQL Server known as a target. NET routines.
1. NET routines can be the following types
1. Storage process?
2. Scalar value of user-defined functions?
3. User-defined function of the type function?
4. User-defined triggers
1. NET stored procedures and SQL stored procedures early in the use of no difference. In an earlier version of SQL Server, the storage process is one or more T-SQL statements. 1. NET stored procedure can be T-SQL and. NET compatible language mixed.
Prepare your first one. NET routines include the following steps (based on the purpose of this article, as I use C #. NET development language):
1. Creation of a category and also quoted System.Data.SqlServer System.Data.Sql
2. Achieved in the open method of business logic
3. Use command-line tools or Visual Studio.NET compile C # procedures
4. Use of this database registration procedures set C #
5. Use of the registration database. NET routines
6. Use of the. NET routines
Based on the purpose of this article, we develop a storage process as our first. NET routines.
You can use Visual Studio.Net or your favorite text editor to prepare the C # procedures.
The following code, and that there is a product database table.
Using System.Data.Sql;
Using System.Data.SqlServer;
/ / /
/ / / This is my first. NET routine.
/ / /
Public class MyNETRoutines
(?
Public static void FirstProc ()
(?
SqlPipe myPipe = SqlContext.GetPipe ();
MyPipe.Send ( "Hello World");
SqlCommand cmd = SqlContext.GetCommand ();
Cmd.CommandText = "select * from product";
MyPipe.Send (cmd.ExecuteReader ());
)
)
Let me explain the above code line by line. Development. NET routines are required for all categories and System.Data.SqlServer System.Data.Sql namespace. These names included in the category of space Sqlcontext for example, can be used to access SQL Server. Unlike ADO.NET, as you need a link, as well as connecting string. Because the procedures set will be loaded into the database, does not need to show the establishment of a connection. 1. NET routines can use In-Process Managed Provider to access SQL Server resources. The above-mentioned namespace contains In-Process Managed Provider realized.
In this paper we focus on two categories: SqlContext and SqlPipe. SqlContext class contains a method can be made an example of a database connection orders. SqlPipe users to send query results and information to the client, and ADO.NET inside Response category there are many similarities.
SqlPipe.Send () has four heavy-duty forms, and the method used to client communications, overloaded as follows:
1. SqlPipe.Send (string meg)
2. SqlPipe.Send (SqlError se)
3. SqlPipe.Send (ISqlRecord record)
4. SqlPipe.Send (ISqlReader reader)
You can send a messge, the reader, error or record to the client process.
Send (string) and send (reader) of a point is: the work of the SQL Server, message sent to news pane, reader sent to the results pane.
In the Yukon beta, System.Data.SqlServer namespace of the procedure is called SqlAccess.dll can use the following command prompt orders above compiler code:
Csc.exe / t: library / r: "
\ Sqlaccess.dll "/ out: MyNETRoutines.dll MyNETRoutines.cs?
Once the program was generated, the procedures set MyNETRoutines.dll includes storage process, the following code used to implement this storage process.
USE AdventureWorks
CREATE ASSEMBLY test from 'C: \ Yukon \ Projects \ MyNETRoutines.dll'
Go
Create procedure FirstProc
As EXTERNAL NAME MyNETRoutines: MyNETRoutines:: FirstProc
Go
Exec FirstProc
?
Figure 1 and Figure 2 is the result of the implementation of
Figure 1
Figure 2
Aggregate
. NET runtime integrated with the database engine for developers to use. NET-based development of complex class library provides a number of business logic flexibility. However, the use of run-time must be aware of the advantages and disadvantages. Therefore, the decision to use T-SQL or. NET compatible language before business logic required to fully taken into account.
————————–
The author introduced
Suhil Srinivas is an experienced developer, the use of Microsoft technology development. Suhil is an MCP, he is very enthusiastic guidance and help beginners. Building Web-based, wireless network and back-office systems has a wealth of experience, and he has done consulting for various enterprises, particularly the Suhil has been engaged in the credit card and payment processing industries. In addition, he or Eduware Knowledge Systems (EKS) Dongshichang. ?
As a company with several EKS apply to the educational institutions of any size products. One of the main products are School-ERP systems, this product completely changed the day-to-day management model educational institutions. Other products, there are some small and medium-sized applied to the medical service providers. EKS also provide advisory services and Bangalore in India through the offices of overseas clients to provide development services.
Tags: implementation, storage








0 Comments to “Preparation of the implementation of your first Yukon CLR (common language runtime) storage process”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.