当前位置: 首页>>代码示例>>C#>>正文


C# SqlQuery.Update方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:frogconn,项目名称:Hospital,代码行数:8,代码来源:DoctorAccessor.cs

示例2: Update

 public void Update(Patient model)
 {
     using (var db = new DbManager())
     {
         var query = new SqlQuery<Patient>();
         query.Update(model);
     }
 }
开发者ID:frogconn,项目名称:Hospital,代码行数:8,代码来源:PatientAccessor.cs

示例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");
            }
        }
开发者ID:vhytyk,项目名称:boginya-journal,代码行数:34,代码来源:JournalView.xaml.cs

示例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");

                    }
                }

            }
        }
开发者ID:vhytyk,项目名称:boginya-journal,代码行数:60,代码来源:JournalView.xaml.cs

示例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;
 }
开发者ID:kyvkri,项目名称:MG,代码行数:22,代码来源:Default.aspx.cs

示例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));
                }
//.........这里部分代码省略.........
开发者ID:kyvkri,项目名称:MG,代码行数:101,代码来源:Default.aspx.cs

示例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();
			}
		}
开发者ID:pbludov,项目名称:bltoolkit,代码行数:34,代码来源:SqlTest.cs

示例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);
            }
        }
开发者ID:starteleport,项目名称:bltoolkit,代码行数:17,代码来源:AssociationTests.cs

示例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);
            }
        }
开发者ID:starteleport,项目名称:bltoolkit,代码行数:30,代码来源:AssociationTests.cs


注:本文中的SqlQuery.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。