This project is read-only.

Arch.Model

Arch.Model give you tools to help you creating entities.

IEntity

IEntity and IEntity<TId> are the 2 interfaces that your entities should implement. They are used in multiples places in Arch#

namespace Arch.Model
{
    public interface IEntity
    {
        bool IsTransient { get; }
    }

    public interface IEntity<TId> : IEntity
    {
        TId Id { get; set; }
    }
}

Entity

Entity<TId> is a class that improve the identity of your entities.
It override the GetHashCode() and Equals() methods with this philosophy:
"If 2 instance of a class represent the same logical business entity so they are equal at the object level."

namespace Arch.Model
{
    [DataContract(IsReference = true)]
    public abstract class Entity : IEntity
    {
        public virtual bool IsTransient { get; }
    }

    [DataContract(Name = "EntityOfType{0}", IsReference = true)]
    public abstract class Entity<TId> : Entity, IEntity<TId>
    {
        [DataMember]
        [Key, Display(AutoGenerateField = false)]
        public virtual TId Id { get; set; }

        public virtual bool IsTransient { get; }

        public override bool Equals(object obj);

        public override int GetHashCode();
    }
}

IValidationErrorInfo

IValidationErrorInfo is an interface that allow you to attach (DataAnnotation) ValidationResult to an entity.
It can be usefull for ntier applications with business validation on the server side.
These properties are automaticaly feeded by the validation interceptor manager.

namespace Arch.Model
{
    public interface IValidationErrorInfo : IEntity
    {
        [Display(AutoGenerateField = false)]
        ICollection<ValidationResult> ValidationErrors { get; }
    }

    public static class ValidationErrorInfoExtentions
    {
        public static void AddError(this IValidationErrorInfo obj, ValidationResult validationResult);
    }
}

Value

The value class dive fonctionnalities to "Value object" (like in DDD) also named "Complex types" in Entity Framework.
Value object are object that has no specific identification in your application. They compose entities.
To check the equality of 2 value object, they compare the value of all properties.

namespace Arch.Model
{
    public class Value
    {
        public override bool Equals(object obj);

        public override int GetHashCode();
    }
}

Last edited Apr 12, 2011 at 10:43 PM by anthyme, version 1

Comments

No comments yet.