Ejemplo n.º 1
0
        private int AddRunnerToDb(ExcelWorksheet workSheet, int row)
        {
            memberList memberList = new memberList();

            memberList.Name     = GetName(workSheet, row);
            memberList.Time     = 0;
            memberList.Distance = 8046.72;
            db.memberLists.Add(memberList);
            db.SaveChanges();
            return(memberList.Id);
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// 创建分组列表缓存
        ///// </summary>
        ///// <typeparam name="keyType">分组字典关键字类型</typeparam>
        ///// <typeparam name="targetType">目标数据类型</typeparam>
        ///// <param name="getKey">分组字典关键字获取器</param>
        ///// <param name="getValue">获取目标对象委托</param>
        ///// <param name="member">缓存字段表达式</param>
        ///// <param name="getTargets">获取缓存目标对象集合</param>
        ///// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        ///// <param name="isReset">是否绑定事件并重置数据</param>
        ///// <returns></returns>
        //public memberList<valueType, modelType, keyType, targetType> CreateMemberList<keyType, targetType>(Func<modelType, keyType> getKey
        //    , Func<keyType, targetType> getValue, Expression<Func<targetType, list<valueType>>> member
        //    , Func<IEnumerable<targetType>> getTargets, bool isRemoveEnd = false, bool isReset = true)
        //    where keyType : IEquatable<keyType>
        //    where targetType : class
        //{
        //    new memberList<valueType, modelType, keyType, targetType>(this, getKey, getValue, member, getTargets, isRemoveEnd, isReset);
        //}
        /// <summary>
        /// 创建分组列表缓存
        /// </summary>
        /// <typeparam name="keyType">分组字典关键字类型</typeparam>
        /// <typeparam name="targetType">目标表格类型</typeparam>
        /// <typeparam name="targetModelType">目标模型类型</typeparam>
        /// <typeparam name="targetMemberCacheType">目标缓存绑定类型</typeparam>
        /// <param name="targetCache">目标缓存</param>
        /// <param name="getKey">分组字典关键字获取器</param>
        /// <param name="member">缓存字段表达式</param>
        /// <param name="isRemoveEnd">移除数据并使用最后一个数据移动到当前位置</param>
        /// <param name="isReset">是否绑定事件并重置数据</param>
        /// <param name="isSave">是否保存缓存对象防止被垃圾回收</param>
        /// <returns></returns>
        public memberList <valueType, modelType, keyType, targetMemberCacheType> CreateMemberList <keyType, targetType, targetModelType, targetMemberCacheType>
            (key <targetType, targetModelType, targetMemberCacheType, keyType> targetCache, Func <modelType, keyType> getKey
            , Expression <Func <targetMemberCacheType, list <valueType> > > member
            , bool isRemoveEnd = false, bool isReset = true, bool isSave = true)
            where keyType : IEquatable <keyType>
            where targetType : class, targetModelType
            where targetModelType : class
            where targetMemberCacheType : class
        {
            memberList <valueType, modelType, keyType, targetMemberCacheType> cache = new memberList <valueType, modelType, keyType, targetMemberCacheType>(this, getKey, targetCache.GetMemberCacheByKey, member, targetCache.GetAllMemberCache, isRemoveEnd, isReset);

            if (isSave)
            {
                memberCaches.Add(cache);
            }
            return(cache);
        }