The version 2.0.0 has extra options than v 1.4.0 as given below:

Usage: o2pgen options
-r, --url Required. URL of OData feed.
-u, --user User name for authentication.
-p, --password password for authentication.
-f, --filename (Default: poco.cs) filename to save generated c# code.
-m, --metafile Xml filename to save metadata.
-v, --verbose (Default: False) Prints C# code to standard output.
-d, --header (Default: False) List http header of the service
-l, --list (Default: False) List POCO classes to standard output.
-k, --key (Default: False) Add Key attribute Key
-t, --table (Default: False) Add Table attribute
-q, --required (Default: False) Add Required attribute
-n, --Navigation (Default: False) Add Navigation Properties
-b, --Nullable (Default: False) Add Nullable Data Types
--help Display this help screen.


example
myprojectfolder\o2p\o2pgen -r http://services.odata.org/V4/OData/OData.svc -f myprojectfolder\northwind.cs -ktqbn
generate c# POCO clases and write to the file myprojectfolder\northwind.cs

sample of output console:

Start processing url: http://services.odata.org/V4/OData/OData.svc
Saving generated code to file : myprojectfolder\northwind.cs

HTTP Header
===============
X-Content-Type-Options: nosniff
OData-Version: 4.0;
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: Accept, Origin, Content-Type, MaxDataServiceVersion
Access-Control-Expose-Headers: DataServiceVersion
Cache-Control: no-cache
Date: Mon, 27 Jun 2016 15:37:58 GMT
Set-Cookie: ARRAffinity=d1815ee9b2e4109e0f2a7e82ec87045272e49afddca1b8d81451712c63389987;Path=/;Domain=services.odata.org
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

POCO classes (count: 11)
====================
1: Address
2: Advertisement http://services.odata.org/V4/OData/OData.svc/Advertisements
3: Category http://services.odata.org/V4/OData/OData.svc/Categories
4: Customer
5: Employee
6: FeaturedProduct
7: Person http://services.odata.org/V4/OData/OData.svc/Persons
8: PersonDetail http://services.odata.org/V4/OData/OData.svc/PersonDetails
9: Product http://services.odata.org/V4/OData/OData.svc/Products
10: ProductDetail http://services.odata.org/V4/OData/OData.svc/ProductDetails
11: Supplier http://services.odata.org/V4/OData/OData.svc/Suppliers

........
Total processing time: 1.215 sec


using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.IO;
using System.Spatial;

//uncomment for spatial data type and run Install-Package System.Spatial
//using System.Spatial;

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated using OData2Poco Class library.
// Service Url: http://services.odata.org/V4/OData/OData.svc
// MetaData Version: 4.0
// </auto-generated>
//------------------------------------------------------------------------------

namespace ODataDemo
{

[Table("Products")]
public class Product
{
[Key]
[Required]
public int ID {get;set;} //PrimaryKey not null
public string Name {get;set;}
public string Description {get;set;}
Required
public DateTimeOffset ReleaseDate {get;set;} // not null
public DateTimeOffset DiscontinuedDate {get;set;}
Required
public short Rating {get;set;} // not null
Required
public double Price {get;set;} // not null
virtual public List<Category> Categories {get;set;}
virtual public Supplier Supplier {get;set;}
virtual public ProductDetail ProductDetail {get;set;}
}

public class FeaturedProduct
{
[Required]
public int ID {get;set;} // not null
public string Name {get;set;}
public string Description {get;set;}
Required
public DateTimeOffset ReleaseDate {get;set;} // not null
public DateTimeOffset DiscontinuedDate {get;set;}
Required
public short Rating {get;set;} // not null
Required
public double Price {get;set;} // not null
public List<Category> Categories {get;set;}
public Supplier Supplier {get;set;}
public ProductDetail ProductDetail {get;set;}
virtual public Advertisement Advertisement {get;set;}
}

Table("ProductDetails")
public class ProductDetail
{
[Key]
[Required]
public int ProductID {get;set;} //PrimaryKey not null
public string Details {get;set;}
virtual public Product Product {get;set;}
}

Table("Categories")
public class Category
{
[Key]
[Required]
public int ID {get;set;} //PrimaryKey not null
public string Name {get;set;}
virtual public List<Product> Products {get;set;}
}

Table("Suppliers")
public class Supplier
{
[Key]
[Required]
public int ID {get;set;} //PrimaryKey not null
public string Name {get;set;}
public Address Address {get;set;}
public GeographyPoint Location {get;set;}
Required
public int Concurrency {get;set;} // not null
virtual public List<Product> Products {get;set;}
}

public class Address
{
public string Street {get;set;}
public string City {get;set;}
public string State {get;set;}
public string ZipCode {get;set;}
public string Country {get;set;}
}

Table("Persons")
public class Person
{
[Key]
[Required]
public int ID {get;set;} //PrimaryKey not null
public string Name {get;set;}
virtual public PersonDetail PersonDetail {get;set;}
}

public class Customer
{
[Required]
public int ID {get;set;} // not null
public string Name {get;set;}
public PersonDetail PersonDetail {get;set;}
Required
public decimal TotalExpense {get;set;} // not null
}

public class Employee
{
[Required]
public int ID {get;set;} // not null
public string Name {get;set;}
public PersonDetail PersonDetail {get;set;}
Required
public long EmployeeID {get;set;} // not null
Required
public DateTimeOffset HireDate {get;set;} // not null
Required
public float Salary {get;set;} // not null
}

Table("PersonDetails")
public class PersonDetail
{
[Key]
[Required]
public int PersonID {get;set;} //PrimaryKey not null
Required
public byte Age {get;set;} // not null
Required
public bool Gender {get;set;} // not null
public string Phone {get;set;}
public Address Address {get;set;}
Required
public Stream Photo {get;set;} // not null
virtual public Person Person {get;set;}
}

Table("Advertisements")
public class Advertisement
{
[Key]
[Required]
public Guid ID {get;set;} //PrimaryKey not null
public string Name {get;set;}
Required
public DateTimeOffset AirDate {get;set;} // not null
virtual public FeaturedProduct FeaturedProduct {get;set;}
}

}

Last edited Jun 27, 2016 at 3:42 PM by mohamed_hassan, version 3