entities - Envivo-Software/Envivo.Fresnel GitHub Wiki

Objects and Entities

Entities are the basic building block of your model.

Create your classes inside the appropriate Subdomain namespace. For Fresnel to display the class, it must have the following:

  • A public constructor
  • A public GUID property named Id
using System;

namespace Acme.OnlineShopping.CustomerAccounts
{
    /// <summary>
    /// A record of a payment for an Order
    /// </summary>
    public class Payment
    {
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public Guid Id { get; set; } //👈

        /// <summary>
        /// The time the payment was made
        /// </summary>
        public DateTime PaidAt { get; set; }

        /// <summary>
        /// The amount paid
        /// </summary>
        public double TotalAmount { get; set; }

        /// <summary>
        /// Any special notes about this payment
        /// </summary>
        public string Notes { get; set; }
    }
}

Alternatively, you can add the Fresnel DomainTypes library, and implement the IEntity interface:

using Envivo.Fresnel.DomainTypes.Interfaces;
using System;

namespace Acme.OnlineShopping.CustomerAccounts
{
    /// <summary>
    /// A record of a payment for an Order
    /// </summary>
    public class Payment : IEntity //👈
    {
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// The time the payment was made
        /// </summary>
        public DateTime PaidAt { get; set; }

        /// <summary>
        /// The amount paid
        /// </summary>
        public double TotalAmount { get; set; }

        /// <summary>
        /// Any special notes about this payment
        /// </summary>
        public string Notes { get; set; }
    }
}

Any code comments appear in the UI as tooltips. This is really useful when demonstrating and discussing your model with other people:

If a class has a public constructor, you can create instances of it in the UI:

A new explorer panel will appear, showing the detail of the entity:

If you need a quick 'summary info' to appear in the explorer's title, overload the ToString() method:

public override string ToString()
{
    return $"{Title} {FirstName} {LastName}";
}

This makes the object easier to identify within the UI:

⚠️ **GitHub.com Fallback** ⚠️