本文整理汇总了C#中PetaPoco.Database.Save方法的典型用法代码示例。如果您正苦于以下问题:C# PetaPoco.Database.Save方法的具体用法?C# PetaPoco.Database.Save怎么用?C# PetaPoco.Database.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PetaPoco.Database
的用法示例。
在下文中一共展示了PetaPoco.Database.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public JsonResult Create(List<Bus> data)
{
bool success = false;
string message = "Create method failed";
if (data != null)
{
using (var db = new PetaPoco.Database("MissNancy"))
{
foreach (var item in data)
{
item.CreateDate = DateTime.Now;
item.EditDate = DateTime.Now;
db.Save("tblBuses", "BusKey", item);
}
success = true;
message = "Jesus Saves and so did this method";
}
}
return Json(new
{
data,
success,
message
});
}
示例2: UpdateUser
public static void UpdateUser(Models.User u)
{
using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
{
db.Save(u);
}
}
示例3: Delete
public JsonResult Delete(IList<Route> data)
{
bool success = false;
string message = "Delete method failed";
if (data != null)
{
using (var db = new PetaPoco.Database("MissNancy"))
{
foreach (var item in data)
{
item.EditDate = DateTime.Now;
item.Active = false;
db.Save("tblRoutes", "RouteKey", item);
}
success = true;
message = "Route(s) deleted successfully";
}
}
return Json(new
{
success,
message
});
}
示例4: AddTarg
/// <summary>
/// 插入标签
/// </summary>
/// <param name="targTitle"></param>
/// <param name="fid"></param>
public static void AddTarg(string targTitle, int fid)
{
using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
{
Models.Targs tag = db.SingleOrDefault<Models.Targs>("WHERE [email protected]", targTitle);
if (tag == null)
{
tag = new Models.Targs();
tag.Forums = fid;
tag.Title = targTitle;
db.Save(tag);
}
Models.TargsRelation tagr = new Models.TargsRelation();
tagr.TagID = tag.TagID;
tagr.ForumsId = fid;
db.Insert(tagr);
}
}
示例5: UpdateForum
public static bool UpdateForum(Models.Forums forum)
{
using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
{
forum.UpdateTime = DateTime.Now;
db.Save(forum);
return true;
}
}
示例6: Edit
public ActionResult Edit(int id, FormCollection collection)
{
var db = new PetaPoco.Database("MissNancy");
var myClass = db.SingleOrDefault<Classes>("SELECT * FROM tblClasses WHERE ClassKey = @0", id);
try
{
UpdateModel(myClass, collection.ToValueProvider());
db.Save("tblClasses", "ClassKey", myClass);
return RedirectToAction("Index");
}
catch (Exception e)
{
return View(myClass);
}
}
示例7: Update
public JsonResult Update(Classes data)
{
bool success = false;
string message = "no record found";
if (data != null && data.ClassKey > 0)
{
using (var db = new PetaPoco.Database("MissNancy"))
{
var rec = db.SingleOrDefault<Classes>("WHERE ClassKey = @0", data.ClassKey);
rec.ClassDisplay = data.ClassDisplay;
db.Save("tblClasses", "ClassKey", rec);
success = true;
message = "Update method called successfully";
}
}
return Json(new
{
data,
success,
message
});
}
示例8: Update
public JsonResult Update(IList<Neighborhood> data)
{
bool success = false;
string message = "no record found";
if (data != null)
{
using (var db = new PetaPoco.Database("MissNancy"))
{
foreach (var item in data)
{
var rec = db.SingleOrDefault<Neighborhood>("WHERE NeighborhoodKey = @0", item.NeighborhoodKey);
rec = item;
rec.EditDate = DateTime.Now;
db.Save("tblNeighborhoods", "NeighborhoodKey", rec);
}
success = true;
message = "Jesus Saves and so did this method";
}
}
return Json(new
{
data,
success,
message
});
}