今天看啥
    热点:

      天发国际娱乐官网:  2016年12月16日,浑水发布报告,称正在做空辉山乳业,并举出大量调查结果,论证这家公司存在财务造假、夸大利润等行为。

      csharp: mappings using Dapper-Extensions+Dapper.net.,


      sql:

      CREATE TABLE [PotoUsers]  
              (  
                [UserID] INT IDENTITY(1,1) PRIMARY KEY,  
                [UserName] NVARCHAR(50),  
                [FirstName] NVARCHAR(50),  
                [LastName] NVARCHAR(50),  
                [MiddleName] NVARCHAR(50),  
                [EmailID] NVARCHAR(50),
      		  [Adddate] datetime  
              )  
      GO  
      

        

       /// <summary>
          /// 20180212
          /// 涂聚文
          /// </summary>
          //[Table("PotoUsers")]
          public class PotoUsers
          {
              /// <summary>
              /// 
              /// </summary>
              //[Key]
              public int UserID { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public string UserName { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public string FirstName { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public string LastName { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public string MiddleName { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public string EmailID { get; set; }
              /// <summary>
              /// 
              /// </summary>
              public DateTime Adddate { get; set; }
      
          }
      

        

       /// <summary>
          /// 涂聚文
          /// 20180212
          /// </summary>
          public static class Mappings
          {      
      
              public static void Initialize()
              {
                  DapperExtensions.DapperExtensions.DefaultMapper = typeof(PluralizedAutoClassMapper<>);
      
                  DapperExtensions.DapperExtensions.SetMappingAssemblies(new[]
                  {
                      typeof(Mappings).Assembly
                  });
              }
              /// <summary>
              /// 
              /// </summary>
              public class PotoUsersMapper : ClassMapper<PotoUsers>
              {
                  /// <summary>
                  /// 
                  /// </summary>
                  public PotoUsersMapper()
                  {
                      Table("PotoUsers"); //DuPotoUsers         
                      Map(Ducel => Ducel.UserID).Column("UserID").Key(KeyType.Identity); //主键类型
                      Map(Ducel => Ducel.UserName).Column("UserName");
                      Map(Ducel => Ducel.FirstName).Column("FirstName");
                      Map(Ducel => Ducel.LastName).Column("LastName");
                      Map(Ducel => Ducel.MiddleName).Column("MiddleName");
                      Map(Ducel => Ducel.EmailID).Column("EmailID");
                      Map(Ducel => Ducel.Adddate).Column("Adddate");
                      AutoMap();
                  }
              }
          } 
      

        

             string  connStr = System.Configuration.ConfigurationManager.ConnectionStrings["conDuString"].ToString();
              /// <summary>
              /// 
              /// </summary>
              /// <param name="sender"></param>
              /// <param name="e"></param>
              protected void Page_Load(object sender, EventArgs e)
              {
                  if (!Page.IsPostBack)
                  {
                      try
                      {
                          using (SqlConnection cn = new SqlConnection(connStr))
                          {
      
                                  //1获取值
                                  //cn.Open();
                                  //int UserID = 1;
                                  //PotoUsers potoUsers = cn.Get<PotoUsers>(UserID);
                                  //cn.Close();
                                  //Response.Write(person.UserName);
      
                               //2插入值
                              //cn.Open();
                              //PotoUsers potoUsers = new PotoUsers { UserName = "geovindu", MiddleName = "", EmailID = "geovindu@163.com", FirstName = "Foo", LastName = "Bar", Adddate = DateTime.Now };
                              //int id = cn.Insert(person);
                              //cn.Close();
      
                              //3 修改
                              //cn.Open();
                              //int UserID = 1;
                              //PotoUsers potoUsers = cn.Get<PotoUsers>(UserID);
                              //potoUsers.UserName = "涂聚文";
                              //potoUsers.LastName = "du";
                              //potoUsers.FirstName = "geovin";
                              //cn.Update(potoUsers);
                              //cn.Close();
      
                              //4.删除
                              //cn.Open();
                              //int UserID = 1;
                              //PotoUsers potoUsers = cn.Get<PotoUsers>(UserID);
                              //cn.Delete(potoUsers);
                              //cn.Close();
      
                              //5.
                              cn.Open();
                              var predicate = Predicates.Field<PotoUsers>(f => f.UserID, Operator.Like, true);
                              IEnumerable<PotoUsers> list = cn.GetList<PotoUsers>(predicate);
                              cn.Close();
                              Response.Write(list.ToList<PotoUsers>().Count.ToString());
      
                          }
                      }
                      catch (SqlException ex)
                      {
                          Response.Write(ex.Message.ToString());
                      }
                  }
      
      
              }
      

       http://www.1click-soft.com/tfgjylgw/zzzprojects/Dapper-Plus

      http://www.1click-soft.com/tfgjylgw/tmsmith/Dapper-Extensions

      http://www.1click-soft.com/tfgjylgw/ericdc1/Dapper.SimpleCRUD

       

      www.1click-soft.comtruehttp://www.1click-soft.com/Asp_Netjc/1304201.htmlTechArticlecsharp: mappings using Dapper-Extensions+Dapper.net., sql: CREATE TABLE [PotoUsers] ( [UserID] INT IDENTITY(1,1) PRIMARY KEY, [UserName] NVARCHAR(50), [FirstName] NVARCHAR(50), [...

      相关文章

      相关搜索: datatable

      帮客评论

      视觉看点
      百度 360 搜狗