bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
136 stars 47 forks source link

Model classes #26

Closed aeadbhard closed 1 year ago

aeadbhard commented 1 year ago

Thanks for such a great library. I want to use it in a project, but I am new to SAP Business One and I am not sure what would I need to do or research in order to create the SAP B1 model classes. What would you recommend? Thanks!

bgmulinari commented 1 year ago

Hi, @aeadbhard.

SAP Business One model classes to be used with B1SLayer can be ordinary C# classes, each representing an entity in SAP and containing its properties. The name and type of each property should match what is defined in the Service Layer metadata.

It's worth noting that your C# model classes don't need to have all the properties of a given SAP entity, as they can have an extensive list of properties and in most cases you will only need a few, which will vary depending on your need.

Here's an example of a model class for the BusinessPartner entity:

public class BusinessPartner
{
    public string CardCode { get; set; }
    public string CardName { get; set; }
    public string CardType { get; set; }
    public string EmailAddress { get; set; }
    public int GroupCode { get; set; }
    // (...) just add all the properties you need, making sure the name and type matches the metadata
}
aeadbhard commented 1 year ago

Thank you, Bruno, for your kind help. Will follow your advice. Thanks!


From: Bruno Mulinari @.> Sent: 07 November 2022 11:30 To: bgmulinari/B1SLayer @.> Cc: aeadbhard @.>; Mention @.> Subject: Re: [bgmulinari/B1SLayer] Model classes (Issue #26)

Hi, @aeadbhardhttps://github.com/aeadbhard.

SAP Business One model classes to be used with B1SLayer can be ordinary C# classes, each representing an entity in SAP and containing its properties. The name and type of each property should match what is defined in the Service Layer metadatahttps://help.sap.com/doc/6ab840ef2e8140f3af9eeb7d8fef9f06/10.0/en-US/Working_with_SAP_Business_One_Service_Layer.pdf#page=20.

It's worth noting that your C# model classes don't need to have all the properties of a given SAP entity, as they can have an extensive list of properties and in most cases you will only need a few, which will vary depending on your need.

Here's an example of a model class for the BusinessPartner entity:

public class BusinessPartner { public string CardCode { get; set; } public string CardName { get; set; } public string CardType { get; set; } public string EmailAddress { get; set; } public int GroupCode { get; set; } // (...) just add all the properties you need, making sure the name and type matches the metadata }

— Reply to this email directly, view it on GitHubhttps://github.com/bgmulinari/B1SLayer/issues/26#issuecomment-1305952091, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AM6HGSGVK6PDHFDGJWS7BKTWHE4D5ANCNFSM6AAAAAARZMLV4I. You are receiving this because you were mentioned.Message ID: @.***>

bgmulinari commented 1 year ago

You're welcome. I'll be closing the issue as your doubt seems to be cleared.