Share Link
Copied to clipboard
Embed on Your Page
Copied to clipboard
We Stand with Ukraine
OData2Poco: User defined attributes by M.Hassan
Demo example for user defined attributes
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated using  OData2Poco System.
//     Service Url: http://services.odata.org/V4/OData/OData.svc
//     MetaData Version: 4.0
//     Generated On: 2025-05-26T12:21:24
//     Parameters: 

// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Spatial;

namespace ODataDemo
{
    // EntitySetName: Products
    [AdaptTo("ProductDto")]
    public partial class Product
    {
        [JsonProperty ("iD")]
        public int ID {get;set;} //PrimaryKey not null

        [JsonProperty ("name")]
        public string Name {get;set;} 

        [JsonProperty ("description")]
        public string Description {get;set;} 

        [JsonProperty ("releaseDate")]
        public DateTimeOffset ReleaseDate {get;set;} // not null

        [JsonProperty ("discontinuedDate")]
        public DateTimeOffset DiscontinuedDate {get;set;} 

        [JsonProperty ("rating")]
        public short Rating {get;set;} // not null

        [JsonProperty ("price")]
        public double Price {get;set;} // not null

    }

    // EntitySetName: FeaturedProduct
    [AdaptTo("FeaturedProductDto")]
    public partial class FeaturedProduct : Product
    {
    }

    // EntitySetName: ProductDetails
    [AdaptTo("ProductDetailDto")]
    public partial class ProductDetail
    {
        [JsonProperty ("productID")]
        public int ProductID {get;set;} //PrimaryKey not null

        [JsonProperty ("details")]
        public string Details {get;set;} 

    }

    // OpenType, EntitySetName: Categories
    [AdaptTo("CategoryDto")]
    public partial class Category
    {
        [JsonProperty ("iD")]
        public int ID {get;set;} //PrimaryKey not null

        [JsonProperty ("name")]
        public string Name {get;set;} 

    }

    // EntitySetName: Suppliers
    [AdaptTo("SupplierDto")]
    public partial class Supplier
    {
        [JsonProperty ("iD")]
        public int ID {get;set;} //PrimaryKey not null

        [JsonProperty ("name")]
        public string Name {get;set;} 

        [JsonProperty ("address")]
        public Address Address {get;set;} 

        [JsonProperty ("location")]
        public GeographyPoint Location {get;set;} 

        [JsonProperty ("concurrency")]
        public int Concurrency {get;set;} // not null

    }

    // Complex Entity
    [AdaptTo("AddressDto")]
    public partial class Address
    {
        [JsonProperty ("street")]
        public string Street {get;set;} 

        [JsonProperty ("city")]
        public string City {get;set;} 

        [JsonProperty ("state")]
        public string State {get;set;} 

        [JsonProperty ("zipCode")]
        public string ZipCode {get;set;} 

        [JsonProperty ("country")]
        public string Country {get;set;} 

    }

    // EntitySetName: Persons
    [AdaptTo("PersonDto")]
    public partial class Person
    {
        [JsonProperty ("iD")]
        public int ID {get;set;} //PrimaryKey not null

        [JsonProperty ("name")]
        public string Name {get;set;} 

    }

    // EntitySetName: Customer
    [AdaptTo("CustomerDto")]
    public partial class Customer : Person
    {
        [JsonProperty ("totalExpense")]
        public decimal TotalExpense {get;set;} // not null

    }

    // EntitySetName: Employee
    [AdaptTo("EmployeeDto")]
    public partial class Employee : Person
    {
        [JsonProperty ("employeeID")]
        public long EmployeeID {get;set;} // not null

        [JsonProperty ("hireDate")]
        public DateTimeOffset HireDate {get;set;} // not null

        [JsonProperty ("salary")]
        public float Salary {get;set;} // not null

    }

    // EntitySetName: PersonDetails
    [AdaptTo("PersonDetailDto")]
    public partial class PersonDetail
    {
        [JsonProperty ("personID")]
        public int PersonID {get;set;} //PrimaryKey not null

        [JsonProperty ("age")]
        public byte Age {get;set;} // not null

        [JsonProperty ("gender")]
        public bool Gender {get;set;} // not null

        [JsonProperty ("phone")]
        public string Phone {get;set;} 

        [JsonProperty ("address")]
        public Address Address {get;set;} 

        [JsonProperty ("photo")]
        public Stream Photo {get;set;} // not null

    }

    // EntitySetName: Advertisements
    [AdaptTo("AdvertisementDto")]
    public partial class Advertisement
    {
        [JsonProperty ("iD")]
        public Guid ID {get;set;} //PrimaryKey not null

        [JsonProperty ("name")]
        public string Name {get;set;} 

        [JsonProperty ("airDate")]
        public DateTimeOffset AirDate {get;set;} // not null

    }

}
Cached Result
Last Run: 2:21:24 pm
Compile: 0.671s
Execute: 0.51s
Memory: 45.05Mb
CPU: 1.181s