/// <summary>
        /// sessionFactory 是单实例对象,一个数据库只有一个
        /// </summary>
        /// <param name="sessionFactory"></param>
        public EntityBase(SessionFactory sessionFactory)
        {
            string cName = this.GetType().Name.PascalToUnderline();

            foreach (CustomAttributeData attributeData in this.GetType().CustomAttributes)
            {
                if (attributeData.AttributeType.Name == "XmlStatementAttribute")
                {
                    cName = (string)attributeData.ConstructorArguments[0].Value;
                }
            }
            session      = sessionFactory.GetSession(cName);
            xmlStatement = new XmlStatement(cName, session.mappings);
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connstring"></param>
 /// <param name="mappingName"></param>
 /// <param name="mappings"></param>
 public Session(string connstring, string mappingName, Dictionary <string, XElement> mappings) : base(connstring)
 {
     this.mappings     = mappings;
     this.mappingName  = mappingName;
     this.xmlStatement = new XmlStatement(mappingName, mappings);
 }