本文整理汇总了C#中PetaPoco.Database.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# PetaPoco.Database.Execute方法的具体用法?C# PetaPoco.Database.Execute怎么用?C# PetaPoco.Database.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PetaPoco.Database
的用法示例。
在下文中一共展示了PetaPoco.Database.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteTarg
/// <summary>
/// 删除掉帖子的所有标签
/// </summary>
/// <param name="fid"></param>
public static void DeleteTarg(int fid)
{
using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
{
db.Execute("DELETE FROM jexus_tags_relation WHERE [email protected]", fid);
}
}
示例2: InitDataBase
public void InitDataBase(string connectionString)
{
var db = new PetaPoco.Database(connectionString, "System.Data.SqlClient");
db.Execute(Const.DBCreateScript);
foreach (var province in ProvinceData.GetProvinces())
{
db.Insert("Province", "Id", new{Name = province.Name, Code = province.Code});
}
var provinces = db.Query<dynamic>(@"SELECT *
from Province").ToList();
BulkUploadToSql bulk =
BulkUploadToSql.Load(
HomeData.GetHomes()
.Select(
i =>
new Bulk.Home
{
AddTime = DateTime.Now,
BuildYear = i.BuildYear,
City = i.City,
Description = i.Description,
Price = i.Price,
Surface = i.Surface,
ProvinceId = provinces.First(j => j.Code == i.HomeProvince.Code).Id,
}), "Home", 10000, connectionString);
bulk.Flush();
}
示例3: DeleteConfirm
public ActionResult DeleteConfirm(long id)
{
DBConnectionString.Student student = DBConnectionString.Student.SingleOrDefault(id);
PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
db.Execute("Delete from UserGroup where [email protected]", student.UserId);
db.Execute("Delete from UserSubjects where [email protected]", student.UserId);
db.Execute("Delete from ELetter where [email protected]", student.UserId);
db.Execute("Delete from Profile where [email protected]", student.UserId);
db.Execute("Delete from Users where [email protected]", student.UserId);
if (student != null)
{
student.Delete();
}
return RedirectToAction("Index");
}
示例4: enable
public ActionResult enable(string[] dulieu,int trang)
{
var db = new PetaPoco.Database("MyConnection");
for (int i = 0; i < dulieu.Length; i++)
{
string qr = string.Format("update hoivien set Disable = '0' where APK = '{0}'", dulieu[i]);
db.Execute(qr);
}
return LoadDefault(trang);
}
示例5: DeleteUserGroup
public bool DeleteUserGroup(long userId, long groupId)
{
int recAffected = 0;
PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
recAffected = db.Execute("delete from UserGroup where UserId = @0 and GroupId = @1", userId, groupId);
if (recAffected > 0)
{
return true;
}
return false;
}
示例6: Post
public object Post([FromBody] SubEstadoContacto item) {
try {
var db = new PetaPoco.Database("jlapc");
var sql = PetaPoco.Sql.Builder
.Append(" INSERT INTO SubEstadoContacto (EstadoContactoID,Descripcion,TipoCuentaID,GrupoID)")
.Append(" VALUES(@0,@1,@2)",item.EstadoContactoID, item.Descripcion, item.TipoCuentaID, item.GrupoID);
db.Execute(sql);
return (new JsonResult() { Data = new { ok = true, error = "", sql = sql }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
} catch (Exception e) {
return (new JsonResult() { Data = new { ok = false, error = e.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
}
}
示例7: DELETE
public object DELETE(int id) {
try {
var db = new PetaPoco.Database("jlapc");
var sql = PetaPoco.Sql.Builder
.Append("DELETE FROM Tema")
.Append("WHERE TemaID= @0", id);
db.Execute(sql);
return (new JsonResult() { Data = new { ok = true, error = "", sql = sql }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
} catch (Exception e) {
return (new JsonResult() { Data = new { ok = false, error = e.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
}
}
示例8: update
public object update([FromBody] EstadoContacto item) {
try {
var db = new PetaPoco.Database("jlapc");
var sql = PetaPoco.Sql.Builder
.Append("UPDATE EstadoContacto")
.Append(" SET Descripcion= @0", item.Descripcion)
.Append("WHERE EstadoContactoID = @0", item.EstadoContactoID);
db.Execute(sql);
return (new JsonResult() { Data = new { ok = true, sql = sql }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
} catch (Exception e) {
return (new JsonResult() { Data = new { ok = false, error = e.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data;
}
}
示例9: enable
public bool enable(string[] dulieu)
{
var db = new PetaPoco.Database("MyConnection");
try{
for (int i = 0; i < dulieu.Length; i++)
{
string qr = string.Format("update hoivien set Disable = '0' where APK = '{0}'", dulieu[i]);
db.Execute(qr);
}return true;
}
catch (Exception e)
{
return false;
};
}
示例10: CheckForTable
private void CheckForTable()
{
if (!File.Exists(_dbFile))
{
using (var db = new PetaPoco.Database(@"Server=.\SQLEXPRESS;Database=master;Integrated Security=SSPI;", "System.Data.SqlClient"))
{
db.Execute(string.Format(@"CREATE DATABASE [Queue] ON PRIMARY (NAME = Queue_Data, FILENAME = '{0}')", _dbFile));
db.Execute("EXEC sp_detach_db 'Queue', 'true'");
}
}
using (var db = GetDb())
{
db.Execute(@"
IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='dbo' AND TABLE_NAME='Jobs')) BEGIN
CREATE TABLE [Jobs] (Id varchar(50) PRIMARY KEY, Created datetime, Processed datetime NULL, Completed datetime NULL, [Type] varchar(MAX) NULL, [Data] varchar(MAX) NULL);
END
");
}
}
示例11: xoa
public bool xoa(string[] dulieu)
{
var db = new PetaPoco.Database("MyConnection");
try{
for (int i = 0; i < dulieu.Length; i++)
{
string qr = string.Format("delete from hoivien where APK = '{0}'", dulieu[i]);
db.Execute(qr);
}return true;
}
catch (Exception e)
{
return false;
};
}
示例12: xoa
public ActionResult xoa(string[] dulieu, int trang)
{
var db = new PetaPoco.Database("MyConnection");
for (int i = 0; i < dulieu.Length; i++)
{
string qr = string.Format("delete from hoivien where APK = '{0}'",dulieu[i]);
db.Execute(qr);
}
return LoadDefault(trang);
}
示例13: Execute
public int Execute(string sql, params object[] args)
{
using (var connection = new SQLiteConnection(ConnectionString))
{
connection.Open();
using (var database = new PetaPoco.Database(connection))
{
return database.Execute(sql, args);
}
}
}
示例14: CreateTable
/// <summary>
/// Creates tables if they don't already exist in the database
/// </summary>
/// <param name="tableName">Name of the table to create</param>
/// <param name="sql">SQL statement for table creation</param>
/// <param name="connectionString">SQL connection string</param>
private static void CreateTable(string tableName, string sql, string connectionString)
{
using (var db = new PetaPoco.Database(connectionString))
{
var count = db.ExecuteScalar<int>(TableExists, tableName);
if (count > 0)
{
return;
}
db.Execute(sql);
}
}
示例15: DeleteStaff
public bool DeleteStaff(long staffId)
{
try
{
PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
var staff = DBConnectionString.Staff.SingleOrDefault(staffId);
db.Execute("delete from RoleUser where User_UserId = @0", staff.UserId);
db.Execute("delete from [Profile] where UserId = @0", staff.UserId);
db.Execute("delete from TeacherSubjects where UserId = @0", staff.UserId);
db.Execute("delete from Staff where StaffId = @0", staffId);
db.Execute("delete from Users where UserId = @0", staff.UserId);
return true;
}
catch
{
return false;
}
}