예제 #1
0
        //public IList<T> GetByExample(T exampleInstance, params string[] propertiesToInclude)
        //{
        //    // get the properties that will be excluded
        //    List<string> propertiesToExclude =
        //        persistentType.GetProperties().Where(p => propertiesToInclude.Contains(p.Name) == false).Select(p => p.Name).ToList();

        //    // create the criteria based on the example and excluding the given properties
        //    ICriteria criteria = HibernateSession.CreateCriteria(persistentType);
        //    Example example = Example.Create(exampleInstance);
        //    foreach (string propertyToExclude in propertiesToExclude) {
        //        example.ExcludeProperty(propertyToExclude);
        //    }
        //    criteria.Add(example);

        //    // return the result
        //    return criteria.List<T>();
        //}



        /// <summary>
        /// For entities that have assigned ID's, you must explicitly call Save to add a new one.
        /// See http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-id-assigned.
        /// </summary>
        public T Save(T entity)
        {
            HibernateSession.Save(entity);
            return(entity);
        }