zoukankan      html  css  js  c++  java
  • single table example 4 of 4

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="TstDBConnection.Entities" assembly="TstDBConnection">
      <class name="Course" table="Course">
        <id name="Id" column="Id">
          <generator class="guid.comb"/>
        </id>
        <property name="Name" column="Name"></property>
        <property name="CreatedDate" column="CreatedOn"></property>
      </class>
    </hibernate-mapping>
    namespace TstDBConnection.Entities
    {
        public class Course
        {
            public virtual Guid Id { get; set; }
            public virtual string Name { get; set; }
            public virtual DateTime CreatedDate { get; set; }
        }
    }
            public static void TestSingleTable(ISessionFactory sessionFactory)
            {
                //Use NHibernate to create an entity and get a list of all entities
                using (ISession session = sessionFactory.OpenSession())
                {
                    Course emp = new Course()
                    {
                        Name = "English",
                        CreatedDate = DateTime.Now
                    };
                    session.Save(emp);
                    session.Flush();
    
                    var query = from course in session.Query<Course>()
                                select course;
                    IList<Course> courses = query.ToList();
                }
            }
            static void Main(string[] args)
            {
                log4net.Config.XmlConfigurator.Configure(); // log4net
                Configuration configuration = new Configuration();
                configuration.Configure();
                ISessionFactory sessionFactory = configuration.BuildSessionFactory();
    
                TestSingleTable(sessionFactory);
    
                sessionFactory.Close();
            }

  • 相关阅读:
    执迷不悟
    splunk设置索引周期和索引大小
    下载地址sqlserver2008r2
    蓝牙
    1、IdentityServer4
    翻译名义集
    sql 字符取数字
    Aerial Images Dataset 航空图像数据集 收集
    基于VGG16模型对猫狗分类任务进行迁移学习
    Apollo配置中心
  • 原文地址:https://www.cnblogs.com/webglcn/p/2673455.html
Copyright © 2011-2022 走看看