IBatisNet使用方法(三)与数据库的简单交互相应的类

 

 把表结构填上,避免理解困难

 

 

Create table Member

(   User_ID int identity(1,1), --自增

    CardNo nvarchar(50) not null,

    [Name] nvarchar(50) not null)

 

 

相关类

namespace ETest.test {

    [Serializable]

    public class Member {                          Member类,包括属性存取

        private int _user_ID;

        private string _name;

        private string _cardNO;

        public string CardNO {

             get { return _cardNO; }

             set { _cardNO = value; }}

public string Name {

             get { return _name; }

             set { _UserName = value; }}

         public int User_ID {

             get { return _user_ID; }

             set { _user_ID = value; }}

    }

public class MemberLogic                       相关逻辑类,包含所有逻辑

 private SqlMapper mapper = null;

        public MemberLogic () {                     构造函数

            DomSqlMapBuilder builder = new DomSqlMapBuilder();

            mapper = builder.Configure();           mapping

     }     

public Member Select(int User_ID)

     {

          return (Member)mapper.QueryForObject("SelectMember", User_ID);

         map的自有方法,返还Member.xml中id为“SelectMember”的执行结果,返还结果为对象

     }

     public void Update(Member member)

     {

           mapper.Update("SaveMember", member);

          map的自有方法,直接对应 Member.xml中id为“SaveMember”的执行.

      }

public void Delete(int User_ID)

     {

           mapper.Update("DeleteMember ", member);

          map的自有方法,直接对应 Member.xml中id为“DeleteMember”的执行.

      } 

 }  

posted @ 2009-02-12 10:25  Roc_Lee  阅读(...)  评论(... 编辑 收藏