/// <summary> /// Construtor padrão. /// </summary> /// <param name="parentUidSetter">Delegate usado para define o identificador unico do pai.</param> /// <param name="parentUidGetter">Delegate usado para recupera o identificador unico do pai.</param> /// <param name="foreignProperty">Propriedade de associação.</param> /// <param name="conditional">Condicional para ser usado na carga.</param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> protected EntityDynamicChildEntry(Action <IEntity, IEntity> parentUidSetter, Func <Colosoft.Data.IModel, int> parentUidGetter, System.Reflection.PropertyInfo foreignProperty, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) { _foreignPropertyName = foreignProperty.Name; _parentUidSetter = parentUidSetter; _parentUidGetter = parentUidGetter; _conditional = conditional; _executePredicate = executePredicate; }
/// <summary> /// Registra uma entrada. /// </summary> /// <param name="entityType">Tipo da entidade associada com a entrada.</param> /// <param name="parentPropertyUidName">Nome da propriedade do pai que faz associação.</param> /// <param name="foreignPropertyName">Nome da propriedade que representa a chave estrangeira.</param> /// <param name="conditional">Condicional usado na carga.</param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> /// <returns></returns> public void Register(Type entityType, string parentPropertyUidName, string foreignPropertyName, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) { entityType.Require("entityType").NotNull(); Type entityModelType = null; var baseType = entityType; while (baseType != typeof(object)) { if (baseType.IsGenericType) { var argument = baseType.GetGenericArguments().FirstOrDefault(); if (argument != null) { if (typeof(Colosoft.Data.IModel).IsAssignableFrom(argument)) { entityModelType = argument; break; } } } baseType = baseType.BaseType; } if (entityModelType == null) { throw new InvalidOperationException(string.Format("Entity type '{0}' not support IEntity<Model>", entityType.FullName)); } var entryType = typeof(EntityDynamicChildEntry <, , , >).MakeGenericType(typeof(TEntity), typeof(TModel), entityType, entityModelType); var constructor = entryType.GetConstructor(new Type[] { typeof(string), typeof(string), typeof(EntityLoaderConditional), typeof(Colosoft.Query.QueryExecutePredicate) }); var entry = (EntityDynamicChildEntry)constructor.Invoke(new object[] { parentPropertyUidName, foreignPropertyName, conditional, executePredicate }); Entries.Add(entry); }
/// <summary> /// Registra uma entrada. /// </summary> /// <param name="entityType">Tipo da entidade associada com a entrada.</param> /// <param name="parentPropertyUidName">Nome da propriedade do pai que faz associação.</param> /// <param name="foreignPropertyName">Nome da propriedade que representa a chave estrangeira.</param> /// <param name="conditional">Condicional usado na carga.</param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> /// <returns></returns> public FluentEntityDynamicChild Register(Type entityType, string parentPropertyUidName, string foreignPropertyName, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) { _owner.Register(entityType, parentPropertyUidName, foreignPropertyName, conditional, executePredicate); return(this); }
/// <summary> /// Registra uma entrada. /// </summary> /// <typeparam name="TEntity1">Tipo da entidade associada com a entrada.</typeparam> /// <typeparam name="TModel1">Tipo do modelo de dados da entidade da entrada.</typeparam> /// <param name="parentPropertyUid">Propriedade que representa o Uid do pai.</param> /// <param name="foreignProperty">Propriedade que representa a chave estrangeira.</param> /// <param name="conditional">Condicional usado na carga.</param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> /// <returns></returns> public FluentEntityDynamicChild Register <TEntity1, TModel1>(System.Linq.Expressions.Expression <Func <TModel, int> > parentPropertyUid, System.Linq.Expressions.Expression <Func <TModel1, int> > foreignProperty, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) where TModel1 : class, Colosoft.Data.IModel where TEntity1 : IEntity <TModel1> { _owner.Entries.Add(new EntityDynamicChildEntry <TEntity, TModel, TEntity1, TModel1>(parentPropertyUid, foreignProperty, conditional, executePredicate)); return(this); }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="parentPropertyUidName"></param> /// <param name="foreignPropertyName"></param> /// <param name="conditional"></param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> public EntityDynamicChildEntry(string parentPropertyUidName, string foreignPropertyName, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) : base(GetParentUidSetter(parentPropertyUidName), GetParentUidGetter(foreignPropertyName), GetProperty <TModel>(foreignPropertyName), conditional, executePredicate) { }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="parentPropertyUid"></param> /// <param name="foreignProperty"></param> /// <param name="conditional"></param> /// <param name="executePredicate">Predicado para executar a consulta do filho.</param> public EntityDynamicChildEntry(System.Linq.Expressions.Expression <Func <TParentModel, int> > parentPropertyUid, System.Linq.Expressions.Expression <Func <TModel, int> > foreignProperty, EntityLoaderConditional conditional, Colosoft.Query.QueryExecutePredicate executePredicate) : base(GetParentUidSetter(foreignProperty), GetParentUidGetter(parentPropertyUid), foreignProperty.GetMember() as System.Reflection.PropertyInfo, conditional, executePredicate) { }