当前位置: 首页>>代码示例>>C#>>正文


C# DbConnection.Insert方法代码示例

本文整理汇总了C#中System.Data.Common.DbConnection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnection.Insert方法的具体用法?C# DbConnection.Insert怎么用?C# DbConnection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Common.DbConnection的用法示例。


在下文中一共展示了DbConnection.Insert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Insert

 public int Insert(TwitterApp entity)
 {
     using (_connection = Utilities.Database.GetProfiledOpenConnection())
     {
         return _connection.Insert(entity).Value;
     }
 }
开发者ID:jdehlin,项目名称:Twitta,代码行数:7,代码来源:TwitterAppRepository.cs

示例2: Insert

 public Holiday Insert(Holiday entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         entity.Id = _connection.Insert(entity);
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:8,代码来源:HolidayRepository.cs

示例3: Insert

 public RestaurantRating Insert(RestaurantRating entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         var insert = _connection.Insert(entity);
         entity.Id = (int)insert;
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:9,代码来源:RestaurantRatingRepository.cs

示例4: Create

 public ActionResult Create(CarViewModel model)
 {
     if (ModelState.IsValid)
     {
         using (_connection = Utilities.GetOpenConnection())
         {
             _connection.Insert(model);
         }
         return RedirectToAction("index");
     }
     return View(model);
 }
开发者ID:acqu13sce,项目名称:Dapper.SimpleCRUD,代码行数:12,代码来源:CarController.cs

示例5: Create

 public ActionResult Create(UserAddEdit viewmodel)
 {
     if (ModelState.IsValid)
     {
         //manual mapping - this would be easier with automapper
         var user = UserAddEdit.MapUserAddEditToUser(viewmodel);
         using (_connection = Utilities.GetOpenConnection())
         {
             _connection.Insert(user);
         }
         return RedirectToAction("index");
     }
     return View(viewmodel);
 }
开发者ID:lancscoder,项目名称:Dapper.SimpleCRUD,代码行数:14,代码来源:UserController.cs

示例6: SaveOrUpdate

 public Job SaveOrUpdate(Job entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.Id > 0)
         {
             entity.Id =_connection.Update(entity);
         }
         else
         {
              entity.Id = _connection.Insert(entity);
         }
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:15,代码来源:JobRepository.cs

示例7: SaveOrUpdate

 public RestaurantOption SaveOrUpdate(RestaurantOption entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.Id > 0)
         {
             _connection.Update(entity);
         }
         else
         {
             int insert = _connection.Insert(entity);
             entity.Id = insert;
         }
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:16,代码来源:RestaurantOptionRepository.cs

示例8: SaveOrUpdate

 public RestaurantType SaveOrUpdate(RestaurantType entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.Id > 0)
         {
             entity.Id = _connection.Update(entity);
         }
         else
         {
             var insert = _connection.Insert(entity);
                 entity.Id = (int)insert;
         }
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:16,代码来源:RestaurantTypeRepository.cs

示例9: SaveOrUpdate

 public JobLog SaveOrUpdate(JobLog entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.JobLogId > 0)
         {
             entity.JobLogId = _connection.Update(entity);
         }
         else
         {
             var insert = _connection.Insert(entity);
                 entity.JobLogId = (int)insert;
         }
         return entity;
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:16,代码来源:JobLogRepository.cs

示例10: Insert

 private static void Insert(DbConnection db, ISagaState data, string correlationId)
 {
     try
     {
         db.Insert(new SagaRow()
         {
             SagaId = SagaRow.GetId(correlationId, data.GetType()),
             Data = data.Serialize().ToByteArray(),
             IsCompleted = false,
             LastChangedOn = DateTime.UtcNow,
             Version = data.AutoTimestamp
         });
     }
     catch (DbException ex)
     {
         if (db.IsUniqueViolation(ex)) throw new SagaExistsException();
      
     }
 }
开发者ID:DomainBus,项目名称:DomainBus.Sql,代码行数:19,代码来源:SagaStorage.cs

示例11: SaveOrUpdate

 public Vote SaveOrUpdate(Vote entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.Id == 0)
             entity.Id = _connection.Insert(entity);
         else
             _connection.Update(entity);
     }
     return entity;
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:11,代码来源:VoteRepository.cs

示例12: Insert

 public int Insert(DBVersion entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         return _connection.Insert(entity);
     }
 }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:7,代码来源:DBVersionRepository.cs


注:本文中的System.Data.Common.DbConnection.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。