当前位置: 首页 > news >正文

想自己做网站该学些什么网站建设服务费怎么写分录

想自己做网站该学些什么,网站建设服务费怎么写分录,如何做国外网站推广,新手做网站详细步骤1) 学习目标通过进一步学习Nhibernate基础知识#xff0c;掌握用Nhiberate实现对级联的支持#xff0c;通过一个简单的用户角色权限系统来体验nhibernate对级联的强大支持。2#xff09;开发环境和必要准备 开发环境为:windows 2003,Visual studio .Net 2005,Sql server 200…1) 学习目标通过进一步学习Nhibernate基础知识掌握用Nhiberate实现对级联的支持通过一个简单的用户角色权限系统来体验nhibernate对级联的强大支持。 2开发环境和必要准备   开发环境为:windows 2003,Visual studio .Net 2005,Sql server 2005 developer edition  必要准备学习前三篇nhibernate学习系列Nhibernate学习之起步篇-1  ,Nhibernate学习起步之many-to-one篇 ,Nhibernate学习之many-to-many篇 3)示例  业务需求实现一个用户角色权限系统一个用户只有一个角色一个角色下有多个用户一个角色下有多个权限一个权限也对应多个角色                      要求: (1).创建一个角色 (2)在该角色上创建两个个用户3)创建两个权限4)指定该角色上的权限列表5)获得一个用户的权限列表  首先看关系数据库关系图:   4)实现步骤:  1.User.csusing System;using System.Collections.Generic;using System.Text;namespace NhibernateSample1{    public class User    {        private int _id;        private string _name;        private string _pwd;        private Role _role;        /**//// summary        /// 编号        /// /summary        public virtual int Id        {            get            {                return _id;            }            set            {                _id  value;            }        }        /**//// summary        /// 名称        /// /summary        public virtual string Name        {            get            {                return _name;            }            set            {                _name  value;            }        }        /**//// summary        /// 密码        /// /summary        public virtual string Pwd        {            get            {                return _pwd;            }            set            {                _pwd  value;            }        }        public virtual Role Role        {            get            {                return _role;            }            set            {                _role  value;            }        }    }}  User.hbm.xml?xml version1.0 encodingutf-8 ?hibernate-mapping xmlnsurn:nhibernate-mapping-2.2  class nameNhibernateSample1.User,NhibernateSample1 tableUsers lazyfalse    id nameId columnId unsaved-value0      generator classnative /    /id    property nameName columnName typestring length64 not-nulltrue uniquetrue/property    property namePwd  columnPwd  typestring length64 not-nulltrue/property    many-to-one nameRole  classNhibernateSample1.Role,NhibernateSample1 columnRoleID/many-to-one   /class/hibernate-mapping 2.Role.csusing System;using System.Collections.Generic;using System.Text;using System.Collections;namespace NhibernateSample1{    public class Role    {        int _roleID;        string _roleName;        IList _list  new  ArrayList();        IList _permissionList  new ArrayList();        public virtual IList PermissionList        {            get            {                return _permissionList;            }            set            {                _permissionList  value;            }        }        public virtual int RoleID        {            get            {                return _roleID;            }            set            {                _roleID  value;            }        }        public virtual IList UserList        {            get            {                return _list;            }            set            {                _list  value;            }        }        public virtual string RoleName        {            get            {                return _roleName;            }            set            {                _roleName  value;            }        }    }} Role.hbm.xml?xml version1.0 encodingutf-8 ?hibernate-mapping xmlnsurn:nhibernate-mapping-2.2  class nameNhibernateSample1.Role,NhibernateSample1 tableRoles lazyfalse    id nameRoleID columnRoleID unsaved-value0      generator classnative /    /id    property nameRoleName  columnRoleName  typestring length64 not-nulltrue/property    bag namePermissionList tableRole_Permissions inversetrue lazyfalse cascadeall      key columnRoleID/      many-to-many classNhibernateSample1.Permission,NhibernateSample1 columnPermissionID/many-to-many    /bag    bag nameUserList tableUsers inversetrue lazyfalse cascadeall      key columnRoleID/      one-to-many classNhibernateSample1.User,NhibernateSample1/one-to-many    /bag  /class/hibernate-mapping 3.Permission.csusing System;using System.Collections.Generic;using System.Text;using System.Collections;namespace NhibernateSample1{    public class Permission    {        int _permissionID;        string _permissionName;        IList _roleList  new ArrayList();        public virtual int PermissionID        {            get            {                return _permissionID;            }            set            {                _permissionID  value;            }        }        public virtual string PermissionName        {            get            {                return _permissionName;            }            set            {                _permissionNamevalue;            }        }        public virtual IList RoleList        {            get            {                return _roleList;            }            set            {                _roleList  value;            }        }    }} Permission.hbm.xml?xml version1.0 encodingutf-8 ?hibernate-mapping xmlnsurn:nhibernate-mapping-2.2  class nameNhibernateSample1.Permission,NhibernateSample1 tablePermissions lazyfalse    id namePermissionID columnPermissionID unsaved-value0      generator classnative /    /id    property namePermissionName columnPermissionName typestring length64 not-nulltrue uniquetrue/property    bag nameRoleList tableRole_Permissions  lazytrue      key columnPermissionID/      many-to-many classNhibernateSample1.Role,NhibernateSample1 columnRoleID/many-to-many    /bag  /class/hibernate-mapping 4。数据操作类UserRolePermissionFixureusing System;using System.Collections.Generic;using System.Text;using System.Collections;using NHibernate;using NHibernate.Cfg;using NHibernate.Tool.hbm2ddl;namespace NhibernateSample1{    public  class UserRolePermissionFixure    {        private ISessionFactory _sessions;         public void Configure()        {            Configuration cfg  GetConfiguration();                  _sessions  cfg.BuildSessionFactory();        }        Configuration GetConfiguration()        {            string cfgPath  E:\my project\nhibernate study\simle 1\NHibernateStudy1\NhibernateSample1\hibernate.cfg.xml;            Configuration cfg  new Configuration().Configure(cfgPath);            return cfg;        }        public void ExportTables()        {            Configuration cfg  GetConfiguration();                       new SchemaExport(cfg).Create(true, true);        }        public Role CreateRole(string roleName)        {            Role r  new Role();            r.RoleName  roleName;            ISession session  _sessions.OpenSession();                        ITransaction tx  null;            try            {                tx  session.BeginTransaction();                session.Save(r);                tx.Commit();            }            catch(Exception e)            {                if (tx ! null) tx.Rollback();                throw e;            }            finally            {                session.Close();            }            return r;        }        public User CreateUser(String name,string pwd,Role r)        {            User u  new User();            u.Name  name;            u.Pwd  pwd;            u.Role  r;            //r.UserList.Add(u);            ISession session  _sessions.OpenSession();            ITransaction tx  null;            try            {                tx  session.BeginTransaction();                session.Save(u);                tx.Commit();            }            catch (HibernateException e)            {                if (tx ! null) tx.Rollback();                throw e;            }            finally            {                session.Close();            }            return u;        }        public Permission CreatePermission(Role r,string name)        {            Permission p  new Permission();            p.PermissionName  name;            r.PermissionList.Add(p);            p.RoleList.Add(r);            ISession session  _sessions.OpenSession();            ITransaction tx  null;            try            {                tx  session.BeginTransaction();                session.Save(p);                tx.Commit();            }            catch (HibernateException e)            {                if (tx ! null) tx.Rollback();                throw e;            }            finally            {                session.Close();            }            return p;        }        public void DeleteRole(int rid)        {            ISession session  _sessions.OpenSession();            ITransaction tx  null;            try            {                tx  session.BeginTransaction();                Role item  session.Load(typeof(Role), rid) as Role;                session.Delete(item);                tx.Commit();            }            catch (HibernateException e)            {                if (tx ! null) tx.Rollback();                throw e;            }            finally            {                session.Close();            }        }    }} 5。单元测试类UnitTest1.csusing System;using System.Text;using System.Collections.Generic;using Microsoft.VisualStudio.TestTools.UnitTesting;using NhibernateSample1;namespace TestProject1{    /**//// summary    /// UnitTest1 的摘要说明    /// /summary    [TestClass]    public class UnitTest1    {        public UnitTest1()        {            //            // TODO: 在此处添加构造函数逻辑            //        }        NhibernateSample1.UserRolePermissionFixure usf  new UserRolePermissionFixure();        其他测试属性#region 其他测试属性        //        // 您可以在编写测试时使用下列其他属性:        //        // 在运行类中的第一个测试之前使用 ClassInitialize 运行代码        // [ClassInitialize()]        // public static void MyClassInitialize(TestContext testContext) { }        //        // 在类中的所有测试都已运行之后使用 ClassCleanup 运行代码        // [ClassCleanup()]        // public static void MyClassCleanup() { }        //        // 在运行每个测试之前使用 TestInitialize 运行代码         // [TestInitialize()]        // public void MyTestInitialize() { }        //        // 在运行每个测试之后使用 TestCleanup 运行代码        // [TestCleanup()]        // public void MyTestCleanup() { }        //        #endregion        [TestMethod]        public void Test1()        {            usf.Configure();            usf.ExportTables();            Role r  usf.CreateRole(test);            Assert.IsTrue(r.RoleID  0);            User u  usf.CreateUser(Guid.NewGuid().ToString(), ds, r);                        Assert.IsTrue(u.Id  0);            Permission p  usf.CreatePermission(r, 查询);            Assert.IsTrue(p.PermissionID  0);                 }    }}    通过本篇的学习将充分理解到nhibernate对级联支持的强大。另外除了支持三级联之外他还支持异类关联(Heterogeneous Associations) .给开发带来了更多的灵活性和实用性。而且考虑到性能的问题还添加了lazy这样的延迟加载的功能加载父亲不必要一定要加载他的儿子集合。通过集合类映射nhinernate轻松实现级联这相比较代码生成来说无疑是一个优点。 转载于:https://www.cnblogs.com/hliq/archive/2008/02/21/2087242.html
http://www.yutouwan.com/news/45291/

相关文章:

  • 网站seo注意事项创意网站建设设计公司
  • 商务网站建设的六个步骤网站建设既有书籍又有光盘
  • 邮轮哪个网站是可以做特价胃肠的wordpress 安全漏洞
  • 网站内容优化网站大图片优化
  • 买app的网站建设枣庄建设工程管理局网站
  • 在网站做推广属于广告费吗wordpress迁移空间后无法显示图片
  • 苏州企业网站建设公司价格网站备案需要去哪里
  • 温州建设银行支行网站上海专业网站建站品
  • 网站建设教程免费夕滋湖南岚鸿官网linux下可以用wordpress
  • 网站建设过程规划和准备阶段网络营销方法有哪几种
  • 大学生个人网站怎么做那些网站做的非常好看
  • 域名 不做网站泉州免费建站模板
  • 网站建设管理规定门户网站建设调查问卷
  • 比较容易做的网站暖暖 视频 在线 观看 高清
  • 适合在线做笔试的网站网站备案密码收不到
  • 温州哪里可以做企业网站网站如果直接点击拨打电话
  • 竞价网站单页怎么样做电影网站
  • 企业网站建设方案 wordphp美食网站开发背景
  • phpstudy 网站空白北滘大良网站制作
  • 做第一个php网站深圳电器公司是国企吗
  • ppt模板免费下载网站哪个好徐州公司网站制作
  • 深圳网站seo 乐云践新贵州新闻
  • 用js做的网站代码吗做网站流程 优帮云
  • 红包打赏的网站怎么做网站建设SEO优化哪家好
  • 锦州网站建设更好网站怎么接入百度地图
  • 网站建设捌金手指下拉十四网站建设的规划和流程
  • 039 织梦云idc网站源码百度怎么做自己的网站
  • 珠海企业集团网站建设代理商加盟项目网站
  • 自助建站申请书大网站
  • 上传网站图片处理新网站怎么做才能让搜狗收录