コード例 #1
0
ファイル: OrmTest.cs プロジェクト: VijayMVC/chalkable
        public void TestQueryBuilding()
        {
            long start  = DateTime.Now.Ticks;
            var  fields = Orm.Fields <User>();

            Debug.WriteLine(fields.JoinString(","));
            var u = new User();

            u.Id          = Guid.NewGuid();
            u.Password    = "******";
            u.Login       = "******";
            u.IsSysAdmin  = true;
            u.IsDeveloper = false;
            var q = Orm.SimpleInsert(u, false);

            Debug.WriteLine(q.Sql);
            Debug.WriteLine(q.Parameters.Select(x => x.Key + "=" + x.Value).JoinString("\n"));

            q = Orm.SimpleUpdate(u);
            Debug.WriteLine(q.Sql);
            Debug.WriteLine(q.Parameters.Select(x => x.Key + "=" + x.Value).JoinString("\n"));

            q = Orm.SimpleDelete(u);
            Debug.WriteLine(q.Sql);
            Debug.WriteLine(q.Parameters.Select(x => x.Key + "=" + x.Value).JoinString("\n"));

            Debug.WriteLine("Duration: " + (DateTime.Now.Ticks - start) / 10000);
        }
コード例 #2
0
        public override void Update(TAnnouncement announcement)
        {
            var conds = new AndQueryCondition {
                { Announcement.ID_FIELD, "annId", announcement.Id, ConditionRelation.Equal }
            };
            var t      = typeof(TAnnouncement);
            var fields = Orm.Fields(t, false, false, true);
            var ps     = new Dictionary <string, object>();

            foreach (var field in fields)
            {
                var fieldValue = t.GetProperty(field).GetValue(announcement);
                ps.Add(field, fieldValue);
            }
            SimpleUpdate <TAnnouncement>(ps, conds);
        }