GLOBAL SITES
 首页 > 产品 > NObject O/R Mapping 框架 > C# 代码示例

更多示例请参考在线文档

插入新对象

Customer customer = new Customer(objectManager);

// ...

customer.Save();

 

Order order = customer.NewOrder();

order.OrderDate = DateTime.Now;

order.ShipCity = city;

// ...

order.Save();

批量更新

Order filter = new Order(objectManager);

filter.ShipVia = 1;

filter.EmployeeID = 7;

 

Order value = new Order(objectManager);

value.ShipVia = 3;

 

// BatchUpdate : using object filter

objectManager.UpdateMatch(filter, value);

 

// BatchUpdate : using OQL

objectManager.ExecuteCommand(

  OQL.Update(NW.Order)

    .Set(NW.Order.ShipVia, 3)

    .Where(NW.Order.ShipVia == 1 & NW.Order.EmployeeID == 7)

  );

对象查询语言 (OQL) 示例 1

// == C# Code ======================================================

SelectQuery qryOrder = OQL

  .SelectWhere(NW.Order == (NW.Customer.ContactTitle == "Owner"));

 

// ==== sql output for Microsoft Sql Server ========================

SELECT [Orders].*

FROM [Orders]

WHERE

  [Orders].[CustomerID] IN

    (

      SELECT [Customers].[CustomerID]

      FROM [Customers]

      WHERE

        [Customers].[ContactTitle] = 'Owner'

    )

 

// ==== sql output for Oracle ======================================

SELECT "Orders".*

FROM "Orders"

WHERE

  "Orders"."CustomerID" IN

    (

      SELECT "Customers"."CustomerID"

      FROM "Customers"

      WHERE

        "Customers"."ContactTitle" = 'Owner'

    ) 

对象查询语言 (OQL) 示例 2

// == C# Code ======================================================

SelectQuery sel = OQL

  .Select(NW.Order.OrderID,NW.Order.OrderDate,NW.Order.RequiredDate)

    ._(NW.OrderDetail)

  .From(NW.Order, NW.OrderDetail)

  .Where(NW.Order.EmployeeID == 5 && NW.Order.ShipVia == 1

    && NW.Order.OrderID == NW.OrderDetail.OrderID)

  .OrderBy(NW.Order.OrderID);

 

==== sql output for Microsoft Sql Server ============================

SELECT

  [Orders].[OrderID] , [Orders].[OrderDate] , [Orders].[RequiredDate]

  , [Order Details].*

FROM

  [Orders] , [Order Details]

WHERE

  [Orders].[EmployeeID] = 5 AND

  [Orders].[ShipVia] = 1 AND

  [Orders].[OrderID] = [Order Details].[OrderID]

ORDER BY [Orders].[OrderID]

 

==== sql output for Oracle =========================================

SELECT

  "Orders"."OrderID" , "Orders"."OrderDate" , "Orders"."RequiredDate"

  , "Order Details".*

FROM

  "Orders" , "Order Details"

WHERE

  "Orders"."EmployeeID" = 5 AND

  "Orders"."ShipVia" = 1 AND

  "Orders"."OrderID" = "Order Details"."OrderID"

ORDER BY "Orders"."OrderID"

概述
特点
下载
购买
系统需求
视频演示
C# 代码示例
VB.NET 代码示例
NObject 用户手册
NObject 帮助
OQL.NET 用户手册
Word to HTML help Word to Web help CHM to Web help CHM to Word CHM to HTML/MHTML .NET assembly Obfuscator