/// <summary>
        /// 
        /// </summary>
        /// <param name="rootAlias"></param>
        /// <param name="rootType"></param>
        /// <param name="matchMode"></param>
        /// <param name="entityMode"></param>
        /// <param name="instance"></param>
        /// <param name="classInfoProvider"></param>
        public CriteriaCompiled(string rootAlias, System.Type rootType, MatchMode matchMode, EntityMode entityMode,
                                object instance, Func<System.Type, IPersistentClassInfo> classInfoProvider)
        {
            
            if (rootAlias == null || rootAlias.Trim().Equals(string.Empty))
                throw new ArgumentException("The alias for making detached criteria cannot be empty or null", "rootAlias");

            if (rootType == null)
                throw new ArgumentNullException("rootType", "The type which can be used for maikng detached criteria cannot be null.");

            if (instance == null)
                throw new ArgumentNullException("instance", "The instance for building detached criteria cannot be null.");

            if (!rootType.IsInstanceOfType(instance))
                throw new ArgumentTypeException("The given instance for building detached criteria is not suitable for the given criteria type.", "instance", rootType, instance.GetType());

            this.matchMode = matchMode ?? MatchMode.Exact;
            this.entityMode = entityMode;
            this.instance = instance;
            this.classInfoProvider = classInfoProvider;

            this.relationshipTree = new RelationshipTree(rootAlias, rootType);
            this.criteria = DetachedCriteria.For(rootType, rootAlias);
            this.restrictions = new List<ICriterion>();
            this.Init();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="alias"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public IRelationshipTree AddRelationship(string name, string alias, System.Type type)
 {
     IRelationshipTree relationship = new RelationshipTree(this, name, alias, type);
     this.relationships.Add(relationship);
     return relationship;
 }