예제 #1
0
        public virtual DTO InsertEx(DTO dto)
        {
            DTO result = null;
            IBaseService <DTO, Entity> service             = this.CreateClient();
            ICommunicationObject       communicationObject = service as ICommunicationObject;

            //string dataerror = service.GetDataError(dto);
            //if ((dataerror != null) && (dataerror != "")) { throw new FaultException<BaseError>(new BaseError(dataerror), new FaultReason(dataerror)); }
            ExtensionMethod.UsingEx <ICommunicationObject>(communicationObject, delegate(ICommunicationObject client)
            {
                result = service.InsertEx(dto);
            });
            return(result);
        }
예제 #2
0
        //public virtual async Task<IList<DTO>> FindAsync(ExpressionNode match)
        //{
        //    Task<IList<DTO>> result = null;
        //    IBaseService<DTO, Entity> service = this.CreateClient();
        //    ICommunicationObject communicationObject = service as ICommunicationObject;
        //    ExtensionMethod.UsingEx<ICommunicationObject>(communicationObject, delegate (ICommunicationObject client)
        //    {
        //        result = service.FindAsync(match);
        //    });
        //    return await result;
        //}

        public virtual IList <DTO> FindWithPager(ExpressionNode match, ref PagerInfo info)
        {
            IList <DTO> result = null;
            IBaseService <DTO, Entity> service             = this.CreateClient();
            ICommunicationObject       communicationObject = service as ICommunicationObject;
            PagerInfo pagerInfo = info;

            ExtensionMethod.UsingEx <ICommunicationObject>(communicationObject, delegate(ICommunicationObject client)
            {
                result = service.FindWithPager(match, ref pagerInfo);
            });
            info.RecordCount = (pagerInfo.RecordCount);
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 插入复数条数据记录
        /// </summary>
        /// <param name="list">新记录集合</param>
        /// <returns>插入后的数据记录集合</returns>
        /// <remarks>
        /// ★使用该方法的时候需要注意,请保证list中的所有对象相互都是数据合法的
        /// 例如,假设合法性校验需要保证【名称】属性不重复,则不能在参数list的中出现多个对象具有相同的【名称】。
        /// 该方法无法阻止这类数据的存储,请开发者自行在调用本方法前进行数据校验
        /// </remarks>
        public virtual IEnumerable <DTO> InsertRangeEx(IEnumerable <DTO> list)
        {
            IEnumerable <DTO>          result  = null;
            IBaseService <DTO, Entity> service = this.CreateClient();
            //foreach (DTO dto in list)
            //{
            //    string dataerror = service.GetDataError(dto);
            //    if ((dataerror != null) && (dataerror != "")) { throw new Exception(dataerror); }
            //}
            ICommunicationObject communicationObject = service as ICommunicationObject;

            ExtensionMethod.UsingEx <ICommunicationObject>(communicationObject, delegate(ICommunicationObject client)
            {
                result = service.InsertRangeEx(list);
            });
            return(result);
        }