GLOBAL SITES
 Home > Products > NObject O/R Mapping Framework > VB.NET Examples

Insert new object

Dim customer1 As Customer = New Customer(objManager)

' ...

customer1.Save()

 

Dim order1 As Order = customer1.NewOrder()

order1.OrderDate = DateTime.Now

order1.ShipCity = city

' ...

order1.Save()

Batch Update

Dim filter As Order = New Order(objManager)

filter.ShipVia = 1

filter.EmployeeID = 7

 

Dim value As Order = New Order(objManager)

value.ShipVia = 3

 

' BatchUpdate : using object filter

objManager.UpdateMatch(filter, value)

 

' BatchUpdate : using OQL

objManager.ExecuteCommand( _

  OQL.Update(NW.Order) _

    .Set(NW.Order.ShipVia, 3) _

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

Object Query Language Sample 1

' == VB.NET Code ================================================

Dim qryOrder As SelectQuery = 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'

    )

Object Query Language Sample 2

' == VB.NET Code ===================================================

Dim sel As SelectQuery = OQL _

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

.Add(NW.OrderDetail) _

.From(NW.Order, NW.Order.OrderDetail) _

.Where(NW.Order.CustomerID = 5 And NW.Order.ShipVia = 1 _

    And 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"

Overview
Features
Download
Purchase
Requirements
Video Demos
C# Examples
VB.NET Examples
NObject Manual
NObject Help
OQL.NET Manual
Word to HTML help Word to Web help CHM to Web help CHM to Word CHM to HTML/MHTML .NET assembly Obfuscator