示例#1
0
 /// <summary>
 /// Create a new Entity. Used to create InMemory Entities that are not persisted to the EAV SqlStore.
 /// </summary>
 public EntityLight(int appId, int entityId, string contentTypeName, Dictionary <string, object> values, string titleAttribute = null, DateTime?modified = null)
 {
     AppId    = appId;
     EntityId = entityId;
     Type     = new ContentType(appId, contentTypeName);
     LightAttributesForInternalUseOnlyForNow = values;//.ConvertToAttributes();
     try
     {
         if (titleAttribute != null)
         {
             TitleFieldName = titleAttribute;
         }
         //Title = Attributes[titleAttribute];
     }
     catch (KeyNotFoundException)
     {
         throw new KeyNotFoundException($"The Title Attribute with Name \"{titleAttribute}\" doesn't exist in the Entity-Attributes.");
     }
     Metadata = new Metadata();
     //IsPublished = true;
     if (modified.HasValue)
     {
         Modified = modified.Value;
     }
     Relationships = new RelationshipManager(this, new EntityRelationshipItem[0]);
 }
示例#2
0
 /// <summary>
 /// Create a new Entity based on an Entity and Attributes
 /// Used in the Attribute-Filter, which generates a new entity with less properties
 /// </summary>
 public Entity(IEntity entity, Dictionary <string, IAttribute> attributes, IEnumerable <EntityRelationshipItem> allRelationships)
 {
     AppId          = entity.AppId;
     EntityId       = entity.EntityId;
     EntityGuid     = entity.EntityGuid;
     Metadata       = ((Metadata)entity.Metadata).CloneIsMetadata();
     Type           = entity.Type;
     TitleFieldName = entity.Title?.Name;
     IsPublished    = entity.IsPublished;
     Attributes     = attributes;
     RepositoryId   = entity.RepositoryId;
     Relationships  = new RelationshipManager(this, allRelationships);
     Owner          = entity.Owner;
 }
示例#3
0
文件: Entity.cs 项目: 2sic/eav-server
        /// <summary>
        /// Create a new Entity based on an Entity and Attributes
        /// </summary>
        public Entity(IEntity entity, Dictionary<string, IAttribute> attributes, IEnumerable<EntityRelationshipItem> allRelationships, string owner)
        {
            EntityId = entity.EntityId;
            EntityGuid = entity.EntityGuid;
            AssignmentObjectTypeId = entity.AssignmentObjectTypeId;
            Type = entity.Type;
            Title = entity.Title;
            IsPublished = entity.IsPublished;
            Attributes = attributes;
            RepositoryId = entity.RepositoryId;
            Relationships = new RelationshipManager(this, allRelationships);

            Owner = owner;
        }
示例#4
0
文件: Entity.cs 项目: 2sic/eav-server
        /// <summary>
        /// Create a new Entity
        /// </summary>
        public Entity(Guid entityGuid, int entityId, int repositoryId, IMetadata metadata /* int assignmentObjectTypeId */, IContentType type, bool isPublished, IEnumerable<EntityRelationshipItem> allRelationships, DateTime modified, string owner)
        {
            EntityId = entityId;
            EntityGuid = entityGuid;
            Metadata = metadata;
            AssignmentObjectTypeId = Metadata.TargetType;// assignmentObjectTypeId;
            Attributes = new Dictionary<string, IAttribute>(StringComparer.OrdinalIgnoreCase); // 2015-04-24 added, maybe a risk but should help with tokens
            Type = type;
            IsPublished = isPublished;
            RepositoryId = repositoryId;
            Modified = modified;

            if (allRelationships == null)
                allRelationships = new List<EntityRelationshipItem>();
            Relationships = new RelationshipManager(this, allRelationships);

            Owner = owner;
        }
示例#5
0
文件: Entity.cs 项目: 2sic/eav-server
 /// <summary>
 /// Create a new Entity. Used to create InMemory Entities that are not persisted to the EAV SqlStore.
 /// </summary>
 public Entity(int entityId, string contentTypeName, IDictionary<string, object> values, string titleAttribute, DateTime? modified = null)
 {
     EntityId = entityId;
     Type = new ContentType(contentTypeName);
     Attributes = AttributeHelperTools.GetTypedDictionaryForSingleLanguage(values, titleAttribute);
     try
     {
         Title = Attributes[titleAttribute];
     }
     catch (KeyNotFoundException)
     {
         throw new KeyNotFoundException(string.Format("The Title Attribute with Name \"{0}\" doesn't exist in the Entity-Attributes.", titleAttribute));
     }
     AssignmentObjectTypeId = Constants.DefaultAssignmentObjectTypeId;
     IsPublished = true;
     if (modified.HasValue)
         Modified = modified.Value;
     Relationships = new RelationshipManager(this, new EntityRelationshipItem[0]);
 }
示例#6
0
        /// <summary>
        /// Create a new Entity from a data store (usually SQL backend)
        /// </summary>
        public Entity(int appId, Guid entityGuid, int entityId, int repositoryId, IMetadata isMetadata, IContentType type, bool isPublished, IEnumerable <EntityRelationshipItem> allRelationships, DateTime modified, string owner, int version)
        {
            AppId        = appId;
            EntityId     = entityId;
            Version      = version;
            EntityGuid   = entityGuid;
            Metadata     = isMetadata;
            Attributes   = new Dictionary <string, IAttribute>(StringComparer.OrdinalIgnoreCase);
            Type         = type;
            IsPublished  = isPublished;
            RepositoryId = repositoryId;
            Modified     = modified;

            if (allRelationships == null)
            {
                allRelationships = new List <EntityRelationshipItem>();
            }
            Relationships = new RelationshipManager(this, allRelationships);

            Owner = owner;
        }