Skip to content

NorthwindModel V4 key

Moh.Hassan edited this page Apr 23, 2019 · 1 revision

To generte POCO model with Attributes: [Key],[Required], [table] and add nullable Datatype symbol, type the command:

    o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc -k -q -t -b	
	Or
	o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc -a key required table	-b

For description of the different options see: CommandLine Reference or help screen

The attributes are added based on the definitions in the Xml MetaData of OData Service:

The generated model is:

	//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated using  OData2Poco Class library.
//     Service Url: http://services.odata.org/V4/Northwind/Northwind.svc/
//     MetaData Version: 4.0
//     Generated On: 2017-04-03T02:36:05
// </auto-generated>
//------------------------------------------------------------------------------

namespace NorthwindModel
{
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

[Table("Categories")]
public class Category
{
    [Required]
    [Key]
     public int CategoryID {get;set;} //PrimaryKey not null

    [Required]
     public string CategoryName {get;set;} // not null

     public string Description {get;set;} 

     public byte[] Picture {get;set;} 

}

[Table("CustomerDemographics")]
public class CustomerDemographic
{
    [Required]
    [Key]
     public string CustomerTypeID {get;set;} //PrimaryKey not null

     public string CustomerDesc {get;set;} 

}

[Table("Customers")]
public class Customer
{
    [Required]
    [Key]
     public string CustomerID {get;set;} //PrimaryKey not null

    [Required]
     public string CompanyName {get;set;} // not null

     public string ContactName {get;set;} 

     public string ContactTitle {get;set;} 

     public string Address {get;set;} 

     public string City {get;set;} 

     public string Region {get;set;} 

     public string PostalCode {get;set;} 

     public string Country {get;set;} 

     public string Phone {get;set;} 

     public string Fax {get;set;} 

}

[Table("Employees")]
public class Employee
{
    [Required]
    [Key]
     public int EmployeeID {get;set;} //PrimaryKey not null

    [Required]
     public string LastName {get;set;} // not null

    [Required]
     public string FirstName {get;set;} // not null

     public string Title {get;set;} 

     public string TitleOfCourtesy {get;set;} 

     public DateTimeOffset? BirthDate {get;set;} 

     public DateTimeOffset? HireDate {get;set;} 

     public string Address {get;set;} 

     public string City {get;set;} 

     public string Region {get;set;} 

     public string PostalCode {get;set;} 

     public string Country {get;set;} 

     public string HomePhone {get;set;} 

     public string Extension {get;set;} 

     public byte[] Photo {get;set;} 

     public string Notes {get;set;} 

     public int? ReportsTo {get;set;} 

     public string PhotoPath {get;set;} 

}

[Table("Order_Details")]
public class Order_Detail
{
    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
     public decimal UnitPrice {get;set;} // not null

    [Required]
     public short Quantity {get;set;} // not null

    [Required]
     public float Discount {get;set;} // not null

}

[Table("Orders")]
public class Order
{
    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public string CustomerID {get;set;} 

     public int? EmployeeID {get;set;} 

     public DateTimeOffset? OrderDate {get;set;} 

     public DateTimeOffset? RequiredDate {get;set;} 

     public DateTimeOffset? ShippedDate {get;set;} 

     public int? ShipVia {get;set;} 

     public decimal? Freight {get;set;} 

     public string ShipName {get;set;} 

     public string ShipAddress {get;set;} 

     public string ShipCity {get;set;} 

     public string ShipRegion {get;set;} 

     public string ShipPostalCode {get;set;} 

     public string ShipCountry {get;set;} 

}

[Table("Products")]
public class Product
{
    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
     public string ProductName {get;set;} // not null

     public int? SupplierID {get;set;} 

     public int? CategoryID {get;set;} 

     public string QuantityPerUnit {get;set;} 

     public decimal? UnitPrice {get;set;} 

     public short? UnitsInStock {get;set;} 

     public short? UnitsOnOrder {get;set;} 

     public short? ReorderLevel {get;set;} 

    [Required]
     public bool Discontinued {get;set;} // not null

}

[Table("Regions")]
public class Region
{
    [Required]
    [Key]
     public int RegionID {get;set;} //PrimaryKey not null

    [Required]
     public string RegionDescription {get;set;} // not null

}

[Table("Shippers")]
public class Shipper
{
    [Required]
    [Key]
     public int ShipperID {get;set;} //PrimaryKey not null

    [Required]
     public string CompanyName {get;set;} // not null

     public string Phone {get;set;} 

}

[Table("Suppliers")]
public class Supplier
{
    [Required]
    [Key]
     public int SupplierID {get;set;} //PrimaryKey not null

    [Required]
     public string CompanyName {get;set;} // not null

     public string ContactName {get;set;} 

     public string ContactTitle {get;set;} 

     public string Address {get;set;} 

     public string City {get;set;} 

     public string Region {get;set;} 

     public string PostalCode {get;set;} 

     public string Country {get;set;} 

     public string Phone {get;set;} 

     public string Fax {get;set;} 

     public string HomePage {get;set;} 

}

[Table("Territories")]
public class Territory
{
    [Required]
    [Key]
     public string TerritoryID {get;set;} //PrimaryKey not null

    [Required]
     public string TerritoryDescription {get;set;} // not null

    [Required]
     public int RegionID {get;set;} // not null

}

[Table("Alphabetical_list_of_products")]
public class Alphabetical_list_of_product
{
    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

     public int? SupplierID {get;set;} 

     public int? CategoryID {get;set;} 

     public string QuantityPerUnit {get;set;} 

     public decimal? UnitPrice {get;set;} 

     public short? UnitsInStock {get;set;} 

     public short? UnitsOnOrder {get;set;} 

     public short? ReorderLevel {get;set;} 

    [Required]
    [Key]
     public bool Discontinued {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string CategoryName {get;set;} //PrimaryKey not null

}

[Table("Category_Sales_for_1997")]
public class Category_Sales_for_1997
{
    [Required]
    [Key]
     public string CategoryName {get;set;} //PrimaryKey not null

     public decimal? CategorySales {get;set;} 

}

[Table("Current_Product_Lists")]
public class Current_Product_List
{
    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

}

[Table("Customer_and_Suppliers_by_Cities")]
public class Customer_and_Suppliers_by_City
{
     public string City {get;set;} 

    [Required]
    [Key]
     public string CompanyName {get;set;} //PrimaryKey not null

     public string ContactName {get;set;} 

    [Required]
    [Key]
     public string Relationship {get;set;} //PrimaryKey not null

}

[Table("Invoices")]
public class Invoice
{
     public string ShipName {get;set;} 

     public string ShipAddress {get;set;} 

     public string ShipCity {get;set;} 

     public string ShipRegion {get;set;} 

     public string ShipPostalCode {get;set;} 

     public string ShipCountry {get;set;} 

     public string CustomerID {get;set;} 

    [Required]
    [Key]
     public string CustomerName {get;set;} //PrimaryKey not null

     public string Address {get;set;} 

     public string City {get;set;} 

     public string Region {get;set;} 

     public string PostalCode {get;set;} 

     public string Country {get;set;} 

    [Required]
    [Key]
     public string Salesperson {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public DateTimeOffset? OrderDate {get;set;} 

     public DateTimeOffset? RequiredDate {get;set;} 

     public DateTimeOffset? ShippedDate {get;set;} 

    [Required]
    [Key]
     public string ShipperName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public decimal UnitPrice {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public short Quantity {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public float Discount {get;set;} //PrimaryKey not null

     public decimal? ExtendedPrice {get;set;} 

     public decimal? Freight {get;set;} 

}

[Table("Order_Details_Extendeds")]
public class Order_Details_Extended
{
    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public int ProductID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public decimal UnitPrice {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public short Quantity {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public float Discount {get;set;} //PrimaryKey not null

     public decimal? ExtendedPrice {get;set;} 

}

[Table("Order_Subtotals")]
public class Order_Subtotal
{
    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public decimal? Subtotal {get;set;} 

}

[Table("Orders_Qries")]
public class Orders_Qry
{
    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public string CustomerID {get;set;} 

     public int? EmployeeID {get;set;} 

     public DateTimeOffset? OrderDate {get;set;} 

     public DateTimeOffset? RequiredDate {get;set;} 

     public DateTimeOffset? ShippedDate {get;set;} 

     public int? ShipVia {get;set;} 

     public decimal? Freight {get;set;} 

     public string ShipName {get;set;} 

     public string ShipAddress {get;set;} 

     public string ShipCity {get;set;} 

     public string ShipRegion {get;set;} 

     public string ShipPostalCode {get;set;} 

     public string ShipCountry {get;set;} 

    [Required]
    [Key]
     public string CompanyName {get;set;} //PrimaryKey not null

     public string Address {get;set;} 

     public string City {get;set;} 

     public string Region {get;set;} 

     public string PostalCode {get;set;} 

     public string Country {get;set;} 

}

[Table("Product_Sales_for_1997")]
public class Product_Sales_for_1997
{
    [Required]
    [Key]
     public string CategoryName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

     public decimal? ProductSales {get;set;} 

}

[Table("Products_Above_Average_Prices")]
public class Products_Above_Average_Price
{
    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

     public decimal? UnitPrice {get;set;} 

}

[Table("Products_by_Categories")]
public class Products_by_Category
{
    [Required]
    [Key]
     public string CategoryName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

     public string QuantityPerUnit {get;set;} 

     public short? UnitsInStock {get;set;} 

    [Required]
    [Key]
     public bool Discontinued {get;set;} //PrimaryKey not null

}

[Table("Sales_by_Categories")]
public class Sales_by_Category
{
    [Required]
    [Key]
     public int CategoryID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string CategoryName {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string ProductName {get;set;} //PrimaryKey not null

     public decimal? ProductSales {get;set;} 

}

[Table("Sales_Totals_by_Amounts")]
public class Sales_Totals_by_Amount
{
     public decimal? SaleAmount {get;set;} 

    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

    [Required]
    [Key]
     public string CompanyName {get;set;} //PrimaryKey not null

     public DateTimeOffset? ShippedDate {get;set;} 

}

[Table("Summary_of_Sales_by_Quarters")]
public class Summary_of_Sales_by_Quarter
{
     public DateTimeOffset? ShippedDate {get;set;} 

    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public decimal? Subtotal {get;set;} 

}

[Table("Summary_of_Sales_by_Years")]
public class Summary_of_Sales_by_Year
{
     public DateTimeOffset? ShippedDate {get;set;} 

    [Required]
    [Key]
     public int OrderID {get;set;} //PrimaryKey not null

     public decimal? Subtotal {get;set;} 

}

}

Clone this wiki locally