本文整理汇总了C#中SandBox.Db.SandBoxDataContext.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# SandBoxDataContext.SubmitChanges方法的具体用法?C# SandBoxDataContext.SubmitChanges怎么用?C# SandBoxDataContext.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SandBox.Db.SandBoxDataContext
的用法示例。
在下文中一共展示了SandBoxDataContext.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateUser
//**********************************************************
//* Создание пользователя
//**********************************************************
public static MembershipUser CreateUser(String username, String password, Int32 roleId)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
var users = UserManager.GetUsers();
if (Enumerable.Any(users, us => us.Login == username)) return null;
User user = new User
{
Login = username,
Password = password,
PasswordSalt = CreateSalt(),
CreatedDate = DateTime.Now,
LastLoginDate = DateTime.Now
};
user.Password = CreatePasswordHash(password, user.PasswordSalt);
db.Users.InsertOnSubmit(user);
db.SubmitChanges();
var usr = db.Users.FirstOrDefault(x => x.Login == username);
if (usr == null) return null;
UsersInRole userInRole = new UsersInRole {UserId = usr.UserId, RoleId = roleId};
db.UsersInRoles.InsertOnSubmit(userInRole);
db.SubmitChanges();
return GetUser(username);
}
}
示例2: AddResearch
//**********************************************************
//* Добавление нового исследования, возвращает researchId
//**********************************************************
public static Int32 AddResearch(Int32 userId, Int32 mlwrId, Int32 vmId, Int32 researchVmData, Int32 duration, String name = "")
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Research research = new Research
{
UserId = userId,
MlwrId = mlwrId,
VmId = vmId,
ResearchVmData = researchVmData,
State = (Int32)ResearchState.READY,
CreatedDate = DateTime.Now,
Duration = duration,
ResearchName = name,
TrafficFileReady = (Int32)TrafficFileReady.NOACTION
};
db.Researches.InsertOnSubmit(research);
db.SubmitChanges();
var researches = from r in db.Researches
where r.UserId == userId
select r.Id;
return researches.Max();
}
}
示例3: DeleteDirectorysOfEvent
public static void DeleteDirectorysOfEvent(long id)
{
var db = new SandBoxDataContext();
var dofe = db.DirectoryOfEvents.FirstOrDefault<DirectoryOfEvents>(x => x.Id == id);
if(dofe!=null) db.DirectoryOfEvents.DeleteOnSubmit(dofe);
db.SubmitChanges();
}
示例4: AddTask
//**********************************************************
//* Добавление новой задачи
//**********************************************************
public static void AddTask(Int32 researchId, Int32 taskType, String value)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Task task = new Task { ResearchId = researchId, Type = taskType, Value = value };
db.Tasks.InsertOnSubmit(task);
db.SubmitChanges();
}
}
示例5: AddReport
public static void AddReport(Int32 researchId, Int32 modId, Int32 actionId, String obj, String target, String additional="")
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Report report = new Report { ResearchId = researchId, ModuleId = modId, ActionId = actionId, Object = obj, Target = target, TIme = DateTime.Now, Additional = additional};
db.Reports.InsertOnSubmit(report);
db.SubmitChanges();
}
}
示例6: AddRole
//**********************************************************
//* Добавление новой роли
//**********************************************************
public static void AddRole(String rolename)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Role role = new Role { Name = rolename };
db.Roles.InsertOnSubmit(role);
db.SubmitChanges();
}
}
示例7: AddRequest
//**********************************************************
//* Добавление нового запроса
//**********************************************************
public static void AddRequest(Int32 researchId, RequestType requestType)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Request request = new Request() {ResearchId = researchId, Type = (Int32)requestType, State = (Int32)RequestState.EXECUTING};
db.Requests.InsertOnSubmit(request);
db.SubmitChanges();
}
}
示例8: DeleteRole
//**********************************************************
//* Удаление роли
//**********************************************************
public static void DeleteRole(String rolename)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Role role = db.Roles.FirstOrDefault(r => r.Name == rolename);
if (role == null) return;
db.Roles.DeleteOnSubmit(role);
db.SubmitChanges();
}
}
示例9: DeleteRequests
//**********************************************************
//* Удалени всех запросов
//**********************************************************
public static void DeleteRequests()
{
var db = new SandBoxDataContext();
var requests = from r in db.Requests
orderby r.Id
select r;
db.Requests.DeleteAllOnSubmit(requests);
db.SubmitChanges();
}
示例10: AddType
//**********************************************************
//* Добавление нового типа Vm
//**********************************************************
public static void AddType(String description)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Int32 maxType = (from t in db.VmTypes orderby t.Type select t.Type).Max();
VmType vmType = new VmType { Type = maxType + 1, Description = description };
db.VmTypes.InsertOnSubmit(vmType);
db.SubmitChanges();
}
}
示例11: AddSystem
//**********************************************************
//* Добавление новой системы Vm
//**********************************************************
public static void AddSystem(String description)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Int32 maxSystem = (from s in db.VmSystems orderby s.System select s.System).Max();
VmSystem vmSystem = new VmSystem { System = maxSystem + 1, Description = description };
db.VmSystems.InsertOnSubmit(vmSystem);
db.SubmitChanges();
}
}
示例12: AddState
//**********************************************************
//* Добавление нового состояния Vm
//**********************************************************
public static void AddState(String description)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Int32 maxState = (from s in db.VmStates orderby s.State select s.State).Max();
VmState vmState = new VmState { State = maxState + 1, Description = description };
db.VmStates.InsertOnSubmit(vmState);
db.SubmitChanges();
}
}
示例13: DeleteItem
public static void DeleteItem(Int32 id)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Machine machine = db.Machines.FirstOrDefault(x => x.Id == id);
db.Machines.DeleteOnSubmit(machine);
db.SubmitChanges();
TableUpdated(Table.MACHINES);
}
}
示例14: CreateItem
public static void CreateItem(String name)
{
using (SandBoxDataContext db = new SandBoxDataContext())
{
Machine machine = new Machine {Name = name, State = -1, UniqueId = 2, Description = "null"};
db.Machines.InsertOnSubmit(machine);
db.SubmitChanges();
TableUpdated(Table.MACHINES);
}
}
示例15: DeleteTasks
//**********************************************************
//* Удалени всех задач
//**********************************************************
public static void DeleteTasks()
{
var db = new SandBoxDataContext();
var tasks = from t in db.Tasks
orderby t.Id
select t;
db.Tasks.DeleteAllOnSubmit(tasks);
db.SubmitChanges();
}