Beispiel #1
0
        public void Save(T updateObj)
        {
            var isCreate = false;
            var found    = MereQuery.Create <T>()
                           .AddFilter(_keyColumn.ColumnName, SqlOperator.EqualTo, _keyColumn.GetBase(updateObj))
                           .ExecuteFirstOrDefault();

//
//
//            if (found == null)
//            {
//                found = updateObj;
//            }
//
//            foreach (var k in d.Keys)
//                {
//                    var col = _mereTable.GetMereColumn(k);
//                    if (col != null)
//                    {
//                        col.Set(found, d[k]);
//                    }
//                }
            isCreate = found != null;
            if (isCreate)
            {
                PubCreate(found);
            }
            else
            {
                PubUpdate(found);
            }
        }
Beispiel #2
0
        public void Save(ExpandoObject updateObj)
        {
            T   found;
            var isCreate = false;
            var d        = (IDictionary <string, object>)updateObj;

            if (d.ContainsKey(_keyColumn.ColumnName))
            {
                found = MereQuery.Create <T>()
                        .AddFilter(_keyColumn.ColumnName, SqlOperator.EqualTo, d[_keyColumn.ColumnName])
                        .ExecuteFirstOrDefault();
            }
            else
            {
                //create
                isCreate = true;
                found    = new T();
            }

            if (found != null)
            {
                foreach (var k in d.Keys)
                {
                    var col = _mereTable.GetMereColumn(k);
                    if (col != null)
                    {
                        col.SetBase(found, d[k]);
                    }
                }
                found.MereSave();
                if (isCreate)
                {
                    PubCreate(found);
                }
                else
                {
                    PubUpdate(found);
                }
            }
        }
Beispiel #3
0
 public static IMereQueryPre <T> Create <T>(MereDataSource dataSource, int top) where T : new()
 {
     return(MereQuery <T> .Create(dataSource, top));
 }
Beispiel #4
0
 public static IMereQueryPre <T> Create <T>(int top) where T : new()
 {
     return(MereQuery <T> .Create(top));
 }