コード例 #1
0
        public IEnumerable <T> ToPoco <T>() where T : new()
        {
            var accessors = GetAccessors <T>();

            if (Edits == null)
            {
                return(new T[0]);
            }

            return(Edits.Select(r =>
            {
                if (r == null)
                {
                    throw new ApplicationException("Received row can't be null");
                }
                if (r.Length != accessors.Length)
                {
                    throw new ApplicationException(string.Format("Received row should have {0} columns. {1} received", accessors.Length, r.Length));
                }
                var res = new T();
                for (int i = 0; i < r.Length; i++)
                {
                    var a = accessors[i];
                    object o = r[i].ToType(null, true, a.PropertyType);
                    a.SetValue(res, o);
                }
                return res;
            }));
        }