程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C# 3.0入門系列(七)--之OR工具介紹(上)(1)

C# 3.0入門系列(七)--之OR工具介紹(上)(1)

編輯:關於C語言

……不得不再次給關注dlinq的朋友道歉了。好久都沒有更新blog了。因為工作的變動,還要趕期限,沒有時間關注這裡了。

先發布一則消息。Orcas Beta1, 這個才是beta1,可以到http://www.microsoft.com/downloads/details.aspx?FamilyID=f10fb5df-e369-4db4-b9a7-845dbf793368&DisplayLang=en 下載。5月1號的版本。最早4月19號就出來過一個,只是沒有在意。還有一個http://www.microsoft.com/downloads/details.ASPx?FamilyID=36b6609e-6f3d-40f4-8c7d-ad111679d8dc&DisplayLang=en 。 一個是self-extracting 版本的,一個是Virtual PC version的。不知道什麼區別。沒有裝過。

本節捨去原來的計劃,而改講映射工具。在入門三一文中,我們提到了sqlmetal這個工具。http://www.cnblogs.com/126/archive/2006/09/06/492332.Html sqlmetal的功能是將數據庫的信息抽提出來,生成映射代碼。Orcas還有另外一個工具,就是O/R Designer.

先講sqlmetal. 自上次的版本後,sqlmetal,又增加了一些新的功能。比如,支持SQLCE版本的SQL Server, 支持直接輸入connection string, 等等。 這是sqlmetal的幫助信息,是不是比上次多了很多?

Microsoft (R) Database Mapping Generator 2008 Beta 2 version 1.00.20612
for Microsoft (R) .Net Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

SqlMetal [options] [<input file>]

 Generates code and mapping for the LINQ to SQL component of the .Net framework. SqlMetal can:
 - Generate source code and mapping attributes or a mapping file from a database.
 - Generate an intermediate dbml file for customization from the database.
 - Generate code and mapping attributes or mapping file from a dbml file.

Options:
 /server:<name>       Database server name.
 /database:<name>      Database catalog on server.
 /user:<name>        Login user ID (default: use Windows Authentication).
 /password:<password>    Login passWord (default: use Windows Authentication).
 /conn:<connection string> Database connection string. Cannot be used with /server, /database, /us
er or /passWord options.
 /timeout:<seconds>     Timeout value to use when SqlMetal Accesses the database (default: 0 wh
ich means infinite).

 /views           Extract database vIEws.
 /functions         Extract database functions.
 /sprocs          Extract stored procedures.

 /dbml[:file]        Output as dbml. Cannot be used with /map option.
 /code[:file]        Output as source code. Cannot be used with /dbml option.
 /map[:file]        Generate mapping file, not attributes. Cannot be used with /dbml option
.

 /language:<language>    Language for source code: VB or C# (default: derived from extension on code file name).
 /namespace:<name>     Namespace of generated code (default: no namespace).
 /context:<type>      Name of data context class (default: derived from database name).
 /entitybase:<type>     Base class of entity classes in the generated code (default: entitIEs have no base class).
 /pluralize         Automatically pluralize or singularize class and member names using English language rules.
 /serialization:<option>  Generate serializable classes: None or Unidirectional (default: None).
 /provider:<type>      Provider type (default: provider is determined at run time).

 <input file>        May be a SqlExpress mdf file, a SqlCE sdf file, or a dbml intermediate file.

Create code from SqlServer:
 SqlMetal /server:myserver /database:northwind /code:nwind.cs /namespace:nwind

Generate intermediate dbml file from SqlServer:
 SqlMetal /server:myserver /database:northwind /dbml:northwind.dbml /namespace:nwind

Generate code with external mapping from dbml:
 SqlMetal /code:nwind.cs /map:nwind.map northwind.dbml

Generate dbml from a SqlCE sdf file:
 SqlMetal /dbml:northwind.dbml northwind.sdf

Generate dbml from SqlExpress local server:
 SqlMetal /server:.\sqlexpress /database:northwind /dbml:northwind.dbml

Generate dbml by using a connection string in the command line:
 SqlMetal /conn:"server='myserver'; database='northwind'" /dbml:northwind.dbml

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved