.NET

.NET SDK for CodeMash API

The database and other services we do provide have REST API on top of it. So each interaction and much more are available using our robust API. (Please check the API documentation section).

Even though working with API can be less joyful than having a well-prepared SDK (Software Development Kit) for your programming language. For this reason, we provide ready-to-production Microsoft. NET SDK that allows you to quickly handle tedious tasks and focus more on your app.

Prerequisites.

Before you jump in, please make sure you have CodeMash API Key.

Get Started

Install CodeMash via NuGet Package manager

Using your preferred editor (Visual Studio, JetBrains Rider, Visual Studio Code, or any other), open your .NET project. Add CodeMash.Code NuGet Package using one of the following ways:

  1. Visual Studio (For more info on how to install the package in Visual Studio, you can find it here.)

    1. Load a project in Solution Explorer, and then select Project > Manage NuGet Packages.

    2. Find CodeMash.Core package and install it.

  2. dotnet CLI (For more info on how to install the package in Visual Studio, you can find it here.)

# using dotnet CLI
dotnet add package CodeMash.Core

You can find the CodeMash npm package here.

Download from source code

Source code is available at https://github.com/codemash-io/CodeMash.Net

You can go to the Releases section and download the build version from the release assets.

Database

Collections

Entities

Entities are your collection data models. In object-oriented programming, this would be a class that is a representation of a collection in your code. Our SDKs provide helper tools to make this representation easier to handle.

Attributes

  • [Collection] - used on a class to specify the name of a collection that this class represents.

  • [Field] - used on property inside of a class to specify the name that is used inside a database. That would be a unique name that you see in your dashboard, collection page, field configuration.

[Collection("persons")]
public class Person : Entity
{
    [Field("name")]
    public string Name { get; set; }
}

The collection attribute allows your requests to the database to be automatically injected with a collection name. The field attribute allows us to correctly serialize and parse your records, filter, sort, projection, and update queries. You can omit this attribute if your property name is exactly the same as your field's unique name.

Interfaces

  • IEntity - an interface that every entity class should implement. This will allow us to use the class in provided database methods.

Classes

  • Entity - a class that already implements IEntity interface and can be extended by your entity classes.

  • TermEntity - a class that should be used for taxonomy references (if your collection has references to taxonomies, use this class for that field).

  • FileEntity - a class that should be used for file fields.

pageFind

Last updated