本文整理汇总了C#中LBT.DAL.DefaultContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultContext.SaveChanges方法的具体用法?C# DefaultContext.SaveChanges怎么用?C# DefaultContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LBT.DAL.DefaultContext
的用法示例。
在下文中一共展示了DefaultContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SavePropertiesBagItem
public static void SavePropertiesBagItem(DefaultContext db, string key, string value, bool saveChangesToDb)
{
lock (LockPropertiesBags)
{
PropertiesBag propertiesBag = _propertiesBags.SingleOrDefault(pb => pb.Key.Equals(key));
if (propertiesBag == null)
{
propertiesBag = new PropertiesBag { Key = key, Value = value };
_propertiesBags.Add(propertiesBag);
}
else
{
propertiesBag.Value = value;
}
PropertiesBag dbPropertiesBag = db.PropertiesBags.Find(key);
if (dbPropertiesBag == null)
{
dbPropertiesBag = new PropertiesBag { Key = key, Value = value };
db.PropertiesBags.Add(dbPropertiesBag);
}
else
{
dbPropertiesBag.Value = value;
}
if (saveChangesToDb)
{
db.SaveChanges();
}
}
}
示例2: Insert
public static void Insert(DefaultContext db, Video video, int[] userIds)
{
db.Videos.Add(video);
VideoUserCache.InsertWithoutSave(db, video.VideoId, userIds);
db.SaveChanges();
}
示例3: Update
public static bool Update(DefaultContext db, ref Currency currency)
{
Currency dbCurrency = GetDetail(db, currency.CurrencyId);
if (dbCurrency == null)
return false;
dbCurrency.CopyFrom(currency);
db.SaveChanges();
currency = dbCurrency;
return true;
}
示例4: SendLazyMails
public static void SendLazyMails(DefaultContext db)
{
DateTime currentTime = DateTime.Now;
LazyMail[] lazyMails = db.LazyMails.Where(lm => lm.TimeToSend <= currentTime).ToArray();
foreach (LazyMail lazyMail in lazyMails)
{
Mail.SendEmail(lazyMail.Address, MailResource.TaskSchedulerController_SendLazyMails_Subject, lazyMail.TextBody, true, true);
db.LazyMails.Remove(lazyMail);
db.SaveChanges();
}
}
示例5: Update
public static bool Update(DefaultContext db, ref District district)
{
District dbDistrict = GetDetail(db, district.DistrictId);
if (dbDistrict == null)
return false;
dbDistrict.CopyFrom(district);
db.SaveChanges();
district = dbDistrict;
return true;
}
示例6: Update
public static bool Update(DefaultContext db, ref MeetingTitleType meetingTitleType)
{
MeetingTitleType dbMeetingTitleType = GetDetail(db, meetingTitleType.MeetingTitleTypeId);
if (dbMeetingTitleType == null)
return false;
dbMeetingTitleType.CopyFrom(meetingTitleType);
db.SaveChanges();
meetingTitleType = dbMeetingTitleType;
return true;
}
示例7: Update
public static bool Update(DefaultContext db, ManualType manualType)
{
int manualTypeId = manualType.ManualTypeId;
ManualType dbManualType = GetDetail(db, manualTypeId);
if (dbManualType == null)
return false;
dbManualType.CopyFrom(manualType);
db.SaveChanges();
return true;
}
示例8: Update
public static bool Update(DefaultContext db, Manual manual)
{
int manualId = manual.ManualId;
Manual dbManual = GetDetail(db, manualId);
if (dbManual == null)
return false;
dbManual.CopyFrom(manual);
db.SaveChanges();
return true;
}
示例9: Update
public static bool Update(DefaultContext db, VideoToken videoToken)
{
int videoTokenId = videoToken.VideoTokenId;
VideoToken dbVideoToken = GetDetail(db, videoTokenId);
if (dbVideoToken == null)
return false;
dbVideoToken.CopyFrom(videoToken);
db.SaveChanges();
return true;
}
示例10: Update
public static bool Update(DefaultContext db, Video video, int[] userIds)
{
int videoId = video.VideoId;
Video dbVideo = GetDetail(db, videoId);
if (dbVideo == null)
return false;
dbVideo.CopyFrom(video);
VideoUserCache.UpdateWithoutSave(db, dbVideo, userIds);
db.SaveChanges();
return true;
}
示例11: Insert
public static VideoToken Insert(DefaultContext db, int videoId, int senderId, int recipientId)
{
var videoToken = new VideoToken
{
Expired = DateTime.Now.AddHours(Properties.Settings.Default.VideoTokenExpirationHours),
VideoId = videoId,
SenderId = senderId,
RecipientId = recipientId
};
db.VideoTokens.Add(videoToken);
db.SaveChanges();
return videoToken;
}
示例12: Delete
public static DeleteResult Delete(DefaultContext db, Manual manual)
{
if (manual == null)
return DeleteResult.AuthorizationFailed;
try
{
db.Manuals.Remove(manual);
db.SaveChanges();
return DeleteResult.Ok;
}
catch (Exception e)
{
Logger.SetLog(e);
return DeleteResult.DbFailed;
}
}
示例13: Delete
/// <summary>
/// Deletes the specified db.
/// </summary>
/// <param name="db">The db.</param>
/// <param name="topTenId">The top ten id.</param>
/// <param name="fromUserId">From user id.</param>
/// <param name="topTen">The top ten.</param>
/// <returns>DeleteResult.</returns>
public static DeleteResult Delete(DefaultContext db, int topTenId, int fromUserId, out TopTen topTen)
{
topTen = GetDetail(db, topTenId, fromUserId);
if (topTen == null)
return DeleteResult.AuthorizationFailed;
try
{
db.TopTens.Remove(topTen);
db.SaveChanges();
return DeleteResult.Ok;
}
catch (Exception e)
{
Logger.SetLog(e);
return DeleteResult.DbFailed;
}
}
示例14: Delete
public static DeleteResult Delete(DefaultContext db, int sharedContactId, out SharedContact sharedContact)
{
sharedContact = GetDetail(db, sharedContactId);
if (sharedContact == null)
return DeleteResult.AuthorizationFailed;
try
{
db.SharedContacts.Remove(sharedContact);
db.SaveChanges();
return DeleteResult.Ok;
}
catch (Exception e)
{
Logger.SetLog(e);
return DeleteResult.DbFailed;
}
}
示例15: ProcessReservationExpiration
public static void ProcessReservationExpiration(DefaultContext db)
{
DateTime maxReserved = DateTime.Now.AddDays(-Properties.Settings.Default.DaysForLockReservation);
MeetingAttendee[] meetingAttendees =
db.MeetingAttendees.Where(
ma =>
ma.Reserved != null && ma.Reserved < maxReserved &&
!ma.Registered.HasValue).ToArray();
foreach (MeetingAttendee meetingAttendee in meetingAttendees)
{
// TODO: Dodělat logování prošlých rezervací
db.MeetingAttendees.Remove(meetingAttendee);
}
db.SaveChanges();
}