コード例 #1
0
        /// <summary>根据主键数组删除数据</summary>
        /// <param name="keys"></param>
        /// <returns>是否删除成功</returns>
        public virtual Boolean[] Delete(Object[] keys)
        {
            if (keys == null)
            {
                return(null);
            }
            if (keys.Length < 1)
            {
                return(new Boolean[0]);
            }

            var rs = new Boolean[keys.Length];

            for (int i = 0; i < keys.Length; i++)
            {
                var entity = Facotry.FindByKey(keys[i]);
                if (entity != null)
                {
                    entity.Delete();
                    rs[i] = true;
                }
            }

            return(rs);
        }
コード例 #2
0
        /// <summary>检查在指定时间后更新过的数据</summary>
        /// <param name="last"></param>
        /// <param name="start"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public virtual ISyncMasterEntity[] GetAllUpdated(DateTime last, Int32 start, Int32 max)
        {
            var name = LastUpdateName;

            var where = String.IsNullOrEmpty(name) ? null : Facotry.MakeCondition(LastUpdateName, last, ">");
            var list = Facotry.FindAll(where, null, null, start, max);

            if (list == null || list.Count < 1)
            {
                return(null);
            }

            // 如果实体类实现了该接口,则返回
            if (Facotry.Default is ISyncMasterEntity)
            {
                var rs = new ISyncMasterEntity[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    rs[i] = list[i] as ISyncMasterEntity;
                }
                return(rs);
            }
            // 否则采用内置实现
            else
            {
                var rs = new ISyncMasterEntity[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    rs[i] = new SyncMasterEntity(this, list[i]);
                }
                return(rs);
            }
        }
コード例 #3
0
        /// <summary>获取指定时间后更新过的数据数量</summary>
        /// <param name="last"></param>
        /// <returns></returns>
        public virtual Int32 GetAllUpdatedCount(DateTime last)
        {
            var name = LastUpdateName;

            var where = String.IsNullOrEmpty(name) ? null : Facotry.MakeCondition(LastUpdateName, last, ">");
            return(Facotry.FindCount(where, null, null, 0, 0));
        }
コード例 #4
0
        public void Test(string productName)
        {
            var product = Facotry.Make(productName);

            product.ShouldNotBeNull();
            product.Name.ShouldBe(productName);
        }
コード例 #5
0
        /// <summary>创建一个空白实体</summary>
        /// <returns></returns>
        public virtual ISyncMasterEntity Create()
        {
            var entity = Facotry.Create();

            if (entity is ISyncMasterEntity)
            {
                return(entity as ISyncMasterEntity);
            }
            else
            {
                return(new SyncMasterEntity(this, entity));
            }
        }
コード例 #6
0
ファイル: ISyncMaster.cs プロジェクト: Underwood12/csharp
        /// <summary>检查在指定时间后更新过的数据</summary>
        /// <param name="last"></param>
        /// <param name="start"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public virtual ISyncMasterEntity[] GetAllUpdated(DateTime last, Int32 start, Int32 max)
        {
            FieldItem fi = Facotry.Table.FindByName(LastUpdateName);

            //var where = fi == null ? null : fi > last;
            var where = new WhereExpression();
            if (fi != null)
            {
                where &= fi > last;
            }
            var list = Facotry.FindAll(where, null, null, start, max);

            if (list == null || list.Count < 1)
            {
                return(null);
            }

            // 如果实体类实现了该接口,则返回
            if (Facotry.Default is ISyncMasterEntity)
            {
                var rs = new ISyncMasterEntity[list.Count];
                for (var i = 0; i < list.Count; i++)
                {
                    rs[i] = list[i] as ISyncMasterEntity;
                }
                return(rs);
            }
            // 否则采用内置实现
            else
            {
                var rs = new ISyncMasterEntity[list.Count];
                for (var i = 0; i < list.Count; i++)
                {
                    rs[i] = new SyncMasterEntity(this, list[i]);
                }
                return(rs);
            }
        }
コード例 #7
0
ファイル: ISyncMaster.cs プロジェクト: xiawei666/X
        /// <summary>根据主键数组检查数据是否仍然存在</summary>
        /// <param name="keys"></param>
        /// <returns>是否存在</returns>
        public virtual Boolean[] CheckExists(Object[] keys)
        {
            if (keys == null)
            {
                return(null);
            }
            if (keys.Length < 1)
            {
                return(new Boolean[0]);
            }

            var rs = new Boolean[keys.Length];

            for (Int32 i = 0; i < keys.Length; i++)
            {
                var entity = Facotry.FindByKey(keys[i]);
                if (entity != null)
                {
                    rs[i] = true;
                }
            }

            return(rs);
        }
コード例 #8
0
ファイル: ISyncMaster.cs プロジェクト: Underwood12/csharp
        /// <summary>获取指定时间后更新过的数据数量</summary>
        /// <param name="last"></param>
        /// <returns></returns>
        public virtual Int64 GetAllUpdatedCount(DateTime last)
        {
            var fi = Facotry.Table.FindByName(LastUpdateName);

            return(Facotry.FindCount(fi > last, null, null, 0, 0));
        }
コード例 #9
0
 public void TestError()
 {
     Assert.Throws <ArgumentNullException>(() => Facotry.Make(null));
     Assert.Throws <ArgumentException>(() => Facotry.Make("Nothing"));
 }