/// <summary> /// Builds an entity instance of the given type out of the given anonymous object /// </summary> /// <param name="entityType">The metadata type information for the entity</param> /// <param name="anonymous">The data as an anonymous type</param> /// <returns>An entity instance with the given values</returns> public EntityInstance EntityInstance(EntityType entityType, object anonymous) { ExceptionUtilities.CheckArgumentNotNull(entityType, "entityType"); EntityInstance instance = new EntityInstance(entityType.FullName, anonymous == null); if (entityType.GetBaseTypesAndSelf().Any(t => t.HasStream())) { instance.AsMediaLinkEntry(); } // TODO: id? if (anonymous != null) { this.PopulatePropertiesFromObject(instance, entityType.AllProperties, anonymous); // TODO: populate navigation properties } return instance; }
/// <summary> /// Constructs an entity with the given property values /// </summary> /// <param name="entityType">The metadata for the entity type</param> /// <param name="namedValues">The property values. Keys are expected to be '.' delimited property paths.</param> /// <returns>An entity instance with the given values</returns> public EntityInstance EntityInstance(EntityType entityType, IEnumerable<NamedValue> namedValues) { ExceptionUtilities.CheckArgumentNotNull(entityType, "entityType"); EntityInstance instance = new EntityInstance(entityType.FullName, namedValues == null); if (entityType.GetBaseTypesAndSelf().Any(t => t.HasStream())) { instance.AsMediaLinkEntry(); } if (namedValues != null) { this.PopulatePropertiesFromPaths(instance, entityType.AllProperties, null, namedValues); // TODO: populate navigation properties } return instance; }