本文整理汇总了C#中SqlQuery.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SqlQuery.Update方法的具体用法?C# SqlQuery.Update怎么用?C# SqlQuery.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.Update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(Doctor model)
{
using (var db = new DbManager())
{
var query = new SqlQuery<Doctor>();
query.Update(model);
}
}
示例2: Update
public void Update(Patient model)
{
using (var db = new DbManager())
{
var query = new SqlQuery<Patient>();
query.Update(model);
}
}
示例3: RemoveJournalItem
public void RemoveJournalItem()
{
if (CanRemoveItem && null != selectedItem &&
MessageBox.Show(string.Format("Ви впевнені що хочете вилучити позицію \"{0}\"?",selectedItem.Name), "вилучення", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
using (DbManager db = new DbManager())
{
db.BeginTransaction();
try
{
if (selectedItem.Tovar != null && !selectedItem.IsRent)
{
//add ostatok in tovar
selectedItem.Tovar.Ostatok += (int)selectedItem.Amount;
SqlQuery<Tovar> query2 = new SqlQuery<Tovar>(db);
query2.Update(selectedItem.Tovar);
}
//insert new journal item
SqlQuery<Journal> query = new SqlQuery<Journal>(db);
query.Delete(selectedItem);
db.CommitTransaction();
}
catch
{
db.RollbackTransaction();
throw;
}
}
PropertyChange("JournalList");
PropertyChange("DaySum");
PropertyChange("InKasaSum");
}
}
示例4: AddJournalItem
public void AddJournalItem()
{
if (!CanAddItem)
return;
FindWindow findWindow = new FindWindow();
FindViewModel viewModel = new FindViewModel();
//viewModel.SelectedTovar = viewModel.TovarList[0];
findWindow.DataContext = viewModel;
if (findWindow.ShowDialog() == true)
{
if (viewModel.SelectedTovar != null)
{
Journal newJournal = new Journal()
{
Amount = 1,
Discount = 0,
ID_Tovar = viewModel.SelectedTovar.ID_Tovar,
Tovar = viewModel.SelectedTovar,
User = User.CurrentUser,
ID_User = User.CurrentUser.ID_User,
Price = viewModel.SelectedTovar.CinaProdazh,
SaleDate = CurrentDate
};
JournalItemView view = new JournalItemView();
view.DataContext = new JournalItemViewModel() { Item = newJournal };
if (view.ShowDialog() == true)
{
using (DbManager db = new DbManager())
{
db.BeginTransaction();
try
{
//inser new journal item
SqlQuery<Journal> query = new SqlQuery<Journal>(db);
query.Insert(newJournal);
if (!newJournal.IsRent) // if it's rent - reduce amount is not needed
{
//reduce ostatok in tovar
newJournal.Tovar.Ostatok -= (int) newJournal.Amount;
SqlQuery<Tovar> query2 = new SqlQuery<Tovar>(db);
query2.Update(newJournal.Tovar);
}
db.CommitTransaction();
}
catch {
db.RollbackTransaction();
throw;
}
}
PropertyChange("JournalList");
PropertyChange("DaySum");
PropertyChange("InKasaSum");
}
}
}
}
示例5: Invoke
public override NextCall Invoke(WorkflowMethod invoker)
{
var dvs = from d in Engine.Definition.DataValue.Values where d.DataValueType == DataValueType.DateTimeType select d.SqlFieldDateTime;
var fields = new List<SqlFieldDateTime>();
foreach (var t in DbTable.GetAllTables(Engine.Definition)) {
foreach (var f in from f in t.Fields where f.DataValueType == DataValueType.DateTimeType select f) fields.Add((SqlFieldDateTime)f);
}
int rowsAffected = 0;
Info.InBackgroundMode = false;
int fieldCount = 0;
int tableCount = dvs.Count();
foreach (var f in fields) {
Info.Caption = "Updating field " + fieldCount + " of " + fields.Count + " fields...";
SqlQuery q = new SqlQuery();
q.Update(f.Table);
q.Where(f < Utils.DateTimeNull);
q.Set(f, Utils.DateTimeNull);
rowsAffected += q.ExecuteNonQuery();
}
Session.Notify(DialogueIcon.Info, "Complete", "Updated " + rowsAffected + " date values in " + tableCount + " fields. ");
return null;
}
示例6: ensureInegrity
void ensureInegrity(object stateInfo)
{
try {
setThreadDescription("Ensuring data uniqueness");
SqlQuery query = new SqlQuery(WAFRuntime.Engine.Dao);
DataAccessObject dao = WAFRuntime.Engine.Dao;
// Node table
setThreadDescription("Fixing Node table..."); int fixCount = 0;
foreach (int nodeId in dao.GetDuplicateNodeRecords()) {
if (dao.FixDuplicateNodeRecords(nodeId)) fixCount++;
}
//if (fixCount > 0) WFContext.Notify("Fixed " + fixCount + " duplicate records in the node table. ");
// NodeCsd table
setThreadDescription("Fixing Node Csd table..."); fixCount = 0;
foreach (int[] ids in dao.GetDuplicateNodeCsdRecords()) {
if (dao.FixDuplicateNodeCsdRecords(ids[0], ids[1])) fixCount++;
}
//if (fixCount > 0) WFContext.Notify("Fixed " + fixCount + " duplicate records in the nodeCsd table. ");
// Content table
setThreadDescription("Fixing Content table..."); fixCount = 0;
foreach (int[] ids in dao.GetDuplicateContentBaseRecords()) {
if (dao.FixDuplicateContentBaseRecords(ids[0], ids[1], ids[2])) fixCount++;
}
//if (fixCount > 0) WAFRuntime.Notify("Fixed " + fixCount + " duplicate records in the content table. ");
// Class tables
foreach (MemDefContentClass classDef in WAFRuntime.Engine.Definition.ContentClass.Values) {
setThreadDescription("Fixing Class table '" + classDef.ClassName + "'..."); fixCount = 0;
List<int> contentIds = dao.GetDuplicateContentClassRecords(classDef.Id);
foreach (int contentId in contentIds) {
if (dao.FixDuplicateContentClassRecords(classDef.Id, contentId)) fixCount++;
}
}
//if (fixCount > 0) WAFRuntime.Notify("Fixed " + fixCount + " duplicate records in class tables. ");
foreach (MemDefRelation relDef in WAFRuntime.Engine.Definition.Relation.Values) {
}
foreach (MemDefProperty propDef in WAFRuntime.Engine.Definition.Property.Values) {
if (propDef.BasePropertyClassId == PropertyBaseClass.InnerContents) {
}
}
AqlAlias alias = new AqlAlias();
alias.IgnoreSessionCulture = true;
alias.IgnoreSessionRevision = true;
alias.IncludeDeletedContents = true;
alias.IncludeDeletedNodes = true;
setThreadDescription("Refreshing derived flag...");
foreach (int siteId in WAFRuntime.Engine.GetAllSiteIds()) {
foreach (int lcid in WAFRuntime.Engine.GetSiteAllLCIDs(siteId)) {
UniqueList<int> cultInSite = new UniqueList<int>(WAFRuntime.Engine.GetSiteLCIDs(siteId));
if (!cultInSite.Contains(lcid)) {
// if lcid is not in site, set all contents in this lcis to derived...
// get all nodes in site
SqlAliasNode node = new SqlAliasNode();
SqlAliasContent content = new SqlAliasContent();
SqlJoinExpression joinExp = new SqlJoinExpression();
joinExp.Add(node.Id, content.NodeId);
SqlFromInnerJoin join = new SqlFromInnerJoin(node, content, joinExp);
SqlQuery select = new SqlQuery(WAFRuntime.Engine.Dao);
select.Select(content.ContentId);
select.From(join);
select.Where(node.SiteId == siteId);
select.Where(content.LCID == lcid);
select.Where(content.IsDerived == false);
List<int> cIds = new List<int>();
using (SqlDataReader dr = select.ExecuteReader()) {
while (dr.Read()) cIds.Add(dr.GetInt(0));
}
foreach (int contentId in cIds) {
SqlQuery update = new SqlQuery(WAFRuntime.Engine.Dao);
update.Update(Sql.Table.Content);
update.Set(Sql.Field.Content.IsDerived, true);
update.Where(Sql.Field.Content.LCID == lcid);
update.Where(Sql.Field.Content.ContentId == contentId);
update.ExecuteNonQuery();
}
if (isThreadCancelled()) return;
}
}
}
setThreadDescription("Retrieving node ids...");
SqlQuery sqlQuery = new SqlQuery(WAFRuntime.Engine.Dao);
List<int> nodeIds = new List<int>();
List<int> classIds = new List<int>();
sqlQuery.From(Sql.Table.Node);
sqlQuery.Distinct = true;
sqlQuery.Select(Sql.Field.Node.Id);
sqlQuery.Select(Sql.Field.Node.ContentClassId);
using (SqlDataReader sqlDr = sqlQuery.ExecuteReader()) {
while (sqlDr.Read()) {
nodeIds.Add(sqlDr.GetInt(0));
classIds.Add(sqlDr.GetInt(1));
}
//.........这里部分代码省略.........
示例7: NonUpdatableOnUpdate
public void NonUpdatableOnUpdate()
{
using (var db = new DbManager())
{
db.BeginTransaction();
var person = new Person1
{
FirstName = "TestOnInsert",
LastName = "",
MiddleName = "1",
Gender = 'M'
};
var sqlQuery = new SqlQuery<Person1>();
sqlQuery.Insert(db, person);
var p = db.GetTable<Person1>().Single(_ => _.FirstName == "TestOnInsert");
Assert.AreEqual(person.MiddleName, p.MiddleName);
person.PersonID = p.PersonID;
person.MiddleName = "should not be updated";
sqlQuery.Update(db, person);
p = db.GetTable<Person1>().Single(_ => _.FirstName == "TestOnInsert");
Assert.AreNotEqual(person.MiddleName, p.MiddleName);
db.RollbackTransaction();
}
}
示例8: TestUpdate
public void TestUpdate()
{
using (var db = _connectionFactory.CreateDbManager())
{
var query = from d in db.GetTable<DataProductPending>()
where d.IdProductPending == 1
select d;
DataProductPending productPending = query.First();
productPending.DateModification = DateTime.Now;
var queryUpdate = new SqlQuery(db);
queryUpdate.Update(productPending);
Console.WriteLine(db.LastQuery);
}
}
示例9: SelectAllArtistsIgnoreLazyLoading
public void SelectAllArtistsIgnoreLazyLoading()
{
using (var db = new MusicDB())
{
var queryI = from a in db.GetTable<Artist>()
where a.Id == 2471
select a;
var aaa = queryI.First();
aaa.Name = "JE NE SUIS PAS UN HÉROS";
var data = new byte[] {0x4A, 0x45, 0x20, 0x4E, 0x45, 0x20, 0x53, 0x55, 0x49, 0x53, 0x20, 0x50, 0x41, 0x53, 0x20, 0x55, 0x4E, 0x20, 0x48, 0xC3, 0x83, 0xC2, 0x89, 0x52, 0x4F, 0x53};
aaa.Name = Encoding.UTF8.GetString(data);
var updateQuery = new SqlQuery(db);
updateQuery.Update(aaa);
var ccc = aaa.Id;
var query2 = new FullSqlQuery(db, true); //loading is automatic
var artist2 = (Artist2) query2.SelectByKey(typeof (Artist2), 2643);
List<Title> titles2 = artist2.Titles;
var query = new FullSqlQuery(db);
var artist = (Artist2) query.SelectByKey(typeof (Artist2), 2643);
List<Title> titles = artist.Titles;
Assert.AreEqual(titles2.Count, titles.Count);
}
}