当你的才华不能撑起你的野心时,就是你该选择学习的时候了!

C# EntityCollection 和 List 互转

        private EntityCollection<T> ToEntityCollection<T>(this List<T> list) where T : class
        {
            EntityCollection<T> entityCollection = new EntityCollection<T>();
            list.ForEach(entityCollection.Add);
            return entityCollection;
        }
        private List<T> ToList<T>(this EntityCollection<T> entityCollection) where T : class
        {
            List<T> list = new List<T>();
            foreach (T model in entityCollection)
            {
                list.Add(model);
            }
            return list;
        }

 

posted @ 2019-10-28 10:27  hofmann  阅读(1805)  评论(1编辑  收藏  举报