本文整理汇总了C#中IDataContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.SaveChanges方法的具体用法?C# IDataContext.SaveChanges怎么用?C# IDataContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.SaveChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
/// <summary>
/// Create a new web by specified web template.
/// </summary>
/// <param name="template">The web template object.</param>
/// <param name="dbContext">The data context object.</param>
/// <param name="name">The new web name.</param>
/// <param name="owner">The new web owner name.</param>
/// <returns>A new web instance created from template.</returns>
public static Web Install(this WebElement template, IDataContext dbContext, string name, string owner)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
var thisWeb = dbContext.Find<Web>(w => w.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
if (thisWeb == null)
{
thisWeb = new Web()
{
Name = name,
Owner = string.IsNullOrEmpty(owner) ? name : owner,
Created = DateTime.UtcNow,
MostOnlined = DateTime.UtcNow,
MostOnlineUserCount = 1,
IsEnabled = true
};
//thisWeb.Popuplate(template);
thisWeb = dbContext.Add(thisWeb);
dbContext.SaveChanges();
}
foreach (var wpTmpl in template.Pages)
wpTmpl.Install(dbContext, thisWeb);
return thisWeb;
}
示例2: _updateRequest
private static Request _updateRequest(Request request, IDataContext dataContext)
{
var dbRequest = dataContext.Requests.Single(_ => _.Id == request.Id);
var dbAuthor = dataContext.Users.Single(_ => _.Id == request.Author.Id);
dbRequest.Author = dbAuthor;
dbRequest.Description = request.Description;
dataContext.SaveChanges();
return dbRequest;
}
示例3: _createRequest
private static Request _createRequest(Request request, IDataContext dataContext)
{
dataContext.CreateRequest(request);
dataContext.SaveChanges();
return request;
}