Exemplo n.º 1
0
        /// <summary>
        /// Find Entity
        /// </summary>
        /// <param name="entityFinder"></param>
        /// <returns></returns>
        public EntityListReadOnly <T> FindEntities(EntityFinder entityFinder)
        {
            EntityListReadOnly <T> returnValue = new EntityListReadOnly <T>();

            this.FindAll(returnValue, entityFinder, PredicateForEntityFinder);
            return(returnValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Find Entity
        /// </summary>
        /// <param name="entityFinder"></param>
        /// <returns></returns>
        public T FindEntity(EntityFinder entityFinder)
        {
            T returnValue = null;
            EntityListReadOnly <T> entityListReadOnly = this.FindEntities(entityFinder);

            if (entityListReadOnly.Count > 0)
            {
                returnValue = entityListReadOnly[0];
            }
            return(returnValue);
        }
Exemplo n.º 3
0
        private bool PredicateForEntityFinder(T obj, object criteria)
        {
            bool         returnValue  = true;
            EntityFinder entityFinder = criteria as EntityFinder;

            if (entityFinder == null)
            {
                throw new ArgumentNullException();
            }

            System.Type type = typeof(T);

            for (int i = 0; i < entityFinder.Count; i++)
            {
                System.Reflection.PropertyInfo property = type.GetProperty(entityFinder.GetKey(i), BINDINGS_ALL_INCLUDING_BASE);
                if ((property == null) || (!entityFinder.GetValue(i).Equals(property.GetValue(obj, null))))
                {
                    returnValue = false;
                    break;
                }
            }
            return(returnValue);
        }