odata2poco - OData2Poco.dotnet.o2pgen 6.4.0-dev-427

o2gen is a CommandLine tool for generating c# and typescript POCO (DTO) classes,interfaces and records from OData feeds with lot of configuration parameters.

PM> Install-Package OData2Poco.dotnet.o2pgen -Version 6.4.0-dev-427 -Source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard

> nuget.exe install OData2Poco.dotnet.o2pgen -Version 6.4.0-dev-427 -Source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard

> dotnet tool install -g OData2Poco.dotnet.o2pgen --version 6.4.0-dev-427 --add-source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard
<DotNetCliToolReference Include="OData2Poco.dotnet.o2pgen" Version="6.4.0-dev-427" />
Copy to clipboard
source https://www.myget.org/F/odata2poco/api/v3/index.json

nuget OData2Poco.dotnet.o2pgen  ~> 6.4.0-dev-427
Copy to clipboard

> choco install OData2Poco.dotnet.o2pgen --version 6.4.0-dev-427 --source https://www.myget.org/F/odata2poco/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "odata2poco" -SourceLocation "https://www.myget.org/F/odata2poco/api/v2"
Install-Module -Name "OData2Poco.dotnet.o2pgen" -RequiredVersion "6.4.0-dev-427" -Repository "odata2poco" -AllowPreRelease
Copy to clipboard

Welcome to OData2Poco

OData2Poco is a code generation tool for generating plain-old CLR objects (POCO/DTO) in c# and typescript from OData feeds. POCO classes can be used in a typed RESTful client OData services. Code generation can be controlled by setting many options.


NuGet Version

NuGet Version

Global Tool NuGet Version

Chocolatey

Continuous integration

Branch Build status
Master Build status

Development packages

The developed packages can be downloaded from myget.org


Give a Star! :star:

If you are using this project, please show your support by giving this project a star!. Thanks!


Features of OData2Poco

  • Generate POCO classes corresponding to the Entities defined in the XML MetaData stored in OData Feeds.
  • Generate c# code classes, classes with init-only properties of c#8 and records.
  • Generate typescript code as a single file or multi files(modules).
  • Generation is based on the Metadata of the service stored on the server/ EDMX xml files or xml string contents.
  • Support http(s) with different methods of authentication. The Supported autherizations are: Basic,Bearer,token,Ntlm,Digest, Custom and Oauth2.
  • Console CommandLine tool Support .NET472 or higher.
  • Class library Support NET6/netstandard2.0/net461.
  • Support Windows or Linux /OS fx (with mono installed) and NET6 (netcore).
  • Packaged as a nuget package in three different packages:
  • A Class library full framework/ netstandard2.0 /NET5 for programming.
  • A console CommandLine tool (one executable file o2pgen.exe)
  • Global net core support NET6 (dotnet-o2pgen).
  • Console tool o2pgen is published as a Chocolatey package.
  • Generating CSharp POCO classes. Other languages may be added in the near future based on the community needs.
  • Convert Data type of EDMX to the corresponding CLR data types.
  • Support Entites, complex data type, Collections and navigation properties.
  • Support OData service version V1..V4
  • Code generation is controlled by setting different options:
    • User defined Atributes for the classes and properties using simple text file with c# Expressions.

    • Built-in Attributes: - Add Key Attributes. - Add Required Attributes to the properties. - Add JsonProperty Attribute to the properties. - Add Table Attribute to the class. - Add DataMember Attribute to the properties and DataContract Attribute to the class. - Add display attribute to the properties. - Add ProtoMember to the properties and ProtoContract to the class to suport Proto Buffer. - Add user defined attribute for the properties.

    • Adding virtual modifier to the properties.

    • Convert name of properties to camelCase or PasCase

    • Add nullable datatypes, e.g. int?.

    • Generate (or not) navigation properties.

    • Generated class follows inheritance hierarchy of OData feed (unless switched-off).

    • Generated class can inherit from a common BaseClass/interface.

    • Define namespace to overwrite the namespace of the model.

    • Filter Entities.

    • Name Mapping of Entities and properties using json file with regex support.

  • Add primary key/mandatory comments to the properties of the class.
  • Rename class/properties that have a name match a c# reserved keyword.
  • Save metadata and generated code to a user defined file name.
  • Support colored console windows /linux /OS fx.
  • Support Microsoft.OData.Edm library version 7.5+ (OData v4).
  • Support Microsoft.Data.Edm library (OData v1-v3).

Features added in V3.2.0:

  • New: Support Windows NTLM authentication(Thanks to @lobster2012-user for help).
  • New: Support Microsoft Digest authentication.
  • New: Support Integrated Windows Authentication, enabling users to log in with their Windows credentials (Issue#19).
  • New: Add jsonProperty(originalName) to properties that are renamed because its name is the same as its enclosing type.
  • New: Show/hide model warning due to renaming properties/classes whose name is a reserved keyword.
  • New: Support abstract class.
  • New: support complex type inheritance
  • New: Add attribute [MaxLength] for max length of string/byte[] properties.
  • Convert EDM.TIME in Odata v3 to TimeSpan.
  • Support multi schema.
  • Support multi containers in OData v3.
  • New feature in v5.0.1
  • New feature in v6.0.

OData2Poco Packages

OData2Poco is available in three flavers:

  • A class library: support NET6/netstandard2.0/net461,download.
  • A Console tool: OData2Poco.CommandLine support net472 (a.k.a o2pgen), download.
  • A .Net Core Global tool dotnet-o2pgen support NET6, download.
  • Checolatey Console tool, download.

Install and Usage

1) OData2Poco.CommandLine o2pgen Console Cli

OData2Poco.CommandLine is a Console application (net472) named o2pgen.

It Can be installed from Nuget Gallery:

   Install-Package OData2Poco.CommandLine 

Executing o2pgen as MsBuild Target

Add the next xml code to the project.csproj:

<Target Name="Odata2PocoRun" BeforeTargets="CoreCompile">
         <PropertyGroup>
			<EnableCodeGeneration>true</EnableCodeGeneration>
               <o2pgen>$(PkgOData2Poco_CommandLine)\tools\o2pgen.exe</o2pgen>
               <options>-r http://services.odata.org/V4/Northwind/Northwind.svc/ -f Model\north.cs</options>
		</PropertyGroup>
		<Message Text="Executing o2pgen.exe" Importance="High" />
		<Exec Condition="$(EnableCodeGeneration)
             Command="$(o2pgen)  $(options)" />
</Target>

The attribute Options is the commandLine arguments. Modify the commandline options as you want. For more details read Getting Start.

Excuting o2pgen from Package Console Manager (PCM):

In visual studio 2019 and higher, o2pgen can be run directly from PowerShell Console (PCM). Its path is set during installation.

Check application is installed:

PM> o2pgen --version

Linux and Mac/OS x support

O2pgen cli can run on Linux and Mac/OS if Mono is installed.


2) OData2Poco global Console Cli (net6.0)

Install from nuget gallary, run the command:

dotnet tool install --global OData2Poco.dotnet.o2pgen

How to use:

Run the command:

   dotnet o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc/
   

For help type: dotnet o2pgen --help

Review Commandline option.

Executing the global tool as Msbuild Target

You can auto run dotnet o2pgen from within MsBuild Target and save code in the project folder.

Add the next Msbuild target to your project and modify command parameters as needed. When the property EnableCodeGeneration is set to false, no code is generated. The generated code is saved to file northwind.cs in the folder Model in the root of the project.

<Target Name="GenerateCode" BeforeTargets="CoreCompile">
		<PropertyGroup>
			<EnableCodeGeneration>true</EnableCodeGeneration>
		</PropertyGroup>
		<Exec  Condition="$(EnableCodeGeneration)"
		  Command="dotnet o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc/ -f $(MSBuildProjectDirectory)\Model\northwind.cs -B">
		</Exec>
	</Target>

3) OData2Poco Class library

Support NET6/netstandard2.0/net461. It can be installed from Nuget Gallery

     Install-Package OData2Poco

Try demo Application in NET6 Online


4) Checolatey Package

From Chocolatey Gallery:

 choco install odata2poco-commandline

Documentation

Read the:Wiki


License

MIT License.


Release Notes

Changes

Privacy Policy

All programs or packages will not transfer any information to other networked systems unless specifically requested by the user or the person installing or operating it.

Code Signing Policy

This project uses free code signing provided by SignPath.io, and a certificate by the SignPath Foundation.

Starting with v6.2, o2pgen.exe and all odata2poco.xxx.nupkg packages are signed. Code signing is applied only to odata2poco project code in the odata2poco repository master branch and built on AppVeyor. The odata2poco.xxx.nupkg packages contain third-party libraries used by odata2poco, which may or may not be signed.

Acknowledgements:

Thank you JetBrains for Resharper open source license signpath

Thank you SignPath for free code signing.

signpath
  • .NETFramework 8.0: 8.0.0.0

Owners

moh-hassan

Authors

Mohamed Hassan

Project URL

https://github.com/moh-hassan/odata2poco

License

Unknown

Tags

code-generation odata charp c# typescript ts dto poco AspNetWebApi WebApi

Info

2 total downloads
0 downloads for version 6.4.0-dev-427
Download (1.22 MB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
6.4.0-dev-427 1.22 MB Mon, 18 Mar 2024 13:24:27 GMT 0
6.4.0-dev-426 1.22 MB Sun, 17 Mar 2024 23:48:35 GMT 0
6.3.2 1.22 MB Mon, 18 Mar 2024 15:07:01 GMT 0
6.3.2-dev-428 1.22 MB Mon, 18 Mar 2024 14:43:37 GMT 0
6.3.1 1.22 MB Sat, 16 Mar 2024 02:44:55 GMT 0
6.3.0 1.22 MB Sat, 16 Mar 2024 02:22:48 GMT 0
6.3.0-dev-422 1.22 MB Sat, 16 Mar 2024 01:54:00 GMT 0
6.3.0-dev-421 1.22 MB Fri, 15 Mar 2024 00:28:23 GMT 0
6.3.0-dev-420 1.22 MB Thu, 14 Mar 2024 22:15:26 GMT 0
6.3.0-dev-419 1.22 MB Thu, 14 Mar 2024 13:32:32 GMT 0
6.3.0-dev-418 1.24 MB Thu, 14 Mar 2024 12:35:46 GMT 0
6.3.0-dev-417 1.22 MB Thu, 14 Mar 2024 12:30:17 GMT 0
6.3.0-dev-416 1.22 MB Wed, 13 Mar 2024 01:34:51 GMT 0
6.3.0-dev-413 1.22 MB Thu, 07 Mar 2024 21:13:34 GMT 0
6.3.0-dev-412 1.22 MB Thu, 07 Mar 2024 15:42:14 GMT 0
6.3.0-dev-411 1.24 MB Thu, 07 Mar 2024 01:54:54 GMT 0
6.3.0-dev-409 1.24 MB Tue, 20 Feb 2024 22:01:59 GMT 0
6.3.0-dev-408 1.24 MB Tue, 20 Feb 2024 21:53:52 GMT 0
6.3.0-dev-406 1.24 MB Sun, 10 Dec 2023 20:15:44 GMT 0
6.3.0-dev-405 1.21 MB Sun, 10 Dec 2023 19:39:24 GMT 0
6.3.0-dev-404 1.24 MB Sat, 09 Dec 2023 19:11:26 GMT 0
6.3.0-dev-403 1.24 MB Sat, 09 Dec 2023 11:22:03 GMT 0
6.3.0-dev-401 1.21 MB Thu, 07 Dec 2023 18:56:55 GMT 0
6.3.0-dev-400 1.21 MB Thu, 07 Dec 2023 17:34:51 GMT 0
6.3.0-dev-399 1.21 MB Thu, 07 Dec 2023 17:29:14 GMT 0
6.3.0-dev-398 1.21 MB Thu, 07 Dec 2023 15:58:42 GMT 0
6.3.0-dev-397 1.21 MB Thu, 07 Dec 2023 15:42:42 GMT 0
6.2.0 1.23 MB Tue, 31 Oct 2023 07:15:41 GMT 2
6.2.0-dev-382 1.23 MB Wed, 25 Oct 2023 23:44:27 GMT 0
6.2.0-dev-381 1.23 MB Wed, 25 Oct 2023 18:20:03 GMT 0
6.1.0 1.22 MB Mon, 25 Sep 2023 13:56:41 GMT 0
6.1.0-dev-93 1.21 MB Wed, 28 Jun 2023 00:30:21 GMT 0
6.1.0-dev-154 1.21 MB Fri, 08 Sep 2023 19:28:18 GMT 0