设为首页 加入收藏

TOP

BLToolkitLinq-provider(一)
2015-11-21 01:53:40 来源: 作者: 【 】 浏览:0
Tags:BLToolkitLinq-provider
  • ?
Introduction
Getting Started
Connecting provider database
Creating a data model
Ideology and programming model
Standard Linq queries
The first acquaintance
Query two tables
Implementation of the standard features
Association
Inheritance
Standard features .NET Framework
Additional features BLToolkit
Select
DML operations
SQL Function
Expanding BLToolkit
SQL function
substitution methods
Reuse expressions
Performance
Performance issues in Linq
CompiledQuery
Conclusion
?

?

Demonstration Project

Introduction

Today Linq does not need a special introduction and recommendations. This technology every day gets more and more spread and still wins more recognition of the developers. BLToolkit just did not go away and offers a Linq-provider to access the databases. The purpose of this document is to provide the right information to support Linq BLToolkit.

Getting Started

Connection database provider

BLToolkit supports the following list of databases:
DB2InformixFirebirdOracleMicrosoft AccessMS SQL 2005MS SQL 2008MySqlPostgreSQLSQLCESQLiteSybase ASE

By default, the library supports only three providers: MS SQL 2008, MS SQL 2005 and Microsoft Access. This is due to the fact that these providers are included in the standard delivery of .NET, and for the rest of the performance you need to install additional components from the database vendors.

To add support for the provider are not included in the standard list, follow these steps:

Add references to the library from the producers of databases in your project.Add the appropriate file with the implementation of the project provider. The source code for all providers located in the directory Data \ DataProvider project BLToolkit or in the same directory as the archive http://bltoolkit.net/download/bltoolkit_bin.zip, if you are using a compiled version BLToolkit.Register BLToolkit provider in your project in the following ways:
using System;

using NUnit.Framework;

using BLToolkit.Data;
using BLToolkit.Data.DataProvider;

namespace HowTo.Data.DataProvider
{
    [TestFixture]
    public class AddDataProvider
    {
        const string connectionString = 
            "Data Source=DBHost;Port=5000;Database=BLToolkitData;Uid=sa";

        [Test]
        public void Test()
        {
            // 3rd party data provider registration.
            //
            DbManager.AddDataProvider(new SybaseDataProvider());

            // It can be configured by App.config.
            // We use this way for the demo purpose only.
            //
            DbManager.AddConnectionString(
                "Sybase",          // Provider name
                "Sybase",          // Configuration
                connectionString); // Connection string

            using (var db = new DbManager("Sybase"))
            {
            }
        }
    }
}

Or, using the configuration file:


      

      
    
       
      

      
       
      

      
       
        

Details of the configuration BLToolkit see. Http://bltoolkit.net/doc/Data/index.htm.

Creating a data model

To construct a Linq query, we need a data model as a set of classes that describe the structure of the database tables and relations between them. Building such a model can be done in the following ways:

Using a special utility generating classes for BLToolkit by Andrei Smirnov.Using template MyGeneration by Andy77.With the data model designer Linq to SQL.By writing data model classes manually.

We will use examples to the standard guinea pig from Microsoft - database Northwind. Script create this database and data model for it can be found in the sample project in this article. Below is given a seed for one of the cla

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/13/13
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Mysql Master Slave Config 下一篇BI-SSAS简介篇

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: