Beispiel #1
0
        /// <summary>
        /// Converts data row to an entity object.
        /// </summary>
        /// <param name="row">A data row.</param>
        /// <returns>The data row converted to a entity object.</returns>
        public static ET FromDataRow(RT row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            return(EntityConverterBase <DT, ET, RT, TT> .CreateConverterInstance().FromDataRowImpl(row));
        }
Beispiel #2
0
        /// <summary>
        /// Converts entity object to a data row.
        /// </summary>
        /// <param name="entity">An entity object.</param>
        /// <returns>The entity object converted to a data row.</returns>
        public static RT ToDataRow(ET entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            TT dataTable = Activator.CreateInstance <TT>();

            return(EntityConverterBase <DT, ET, RT, TT> .CreateConverterInstance().ToDataRowImpl(entity, dataTable));
        }
Beispiel #3
0
        /// <summary>
        /// Converts data table to an entity collection.
        /// </summary>
        /// <param name="rows">The data rows.</param>
        /// <returns>The collection of entity objects converted from data rows.</returns>
        public static IList <ET> FromDataTable(IEnumerable rows)
        {
            EntityConverterBase <DT, ET, RT, TT> converter = EntityConverterBase <DT, ET, RT, TT> .CreateConverterInstance();

            List <ET> result = new List <ET>();

            foreach (RT row in rows)
            {
                result.Add(converter.FromDataRowImpl(row));
            }

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Converts entity collection to a data table.
        /// </summary>
        /// <param name="entity">A collection containing entity objects.</param>
        /// <returns>The data table with entity objects converted to data rows.</returns>
        public static TT ToDataTable(IEnumerable <ET> entityCollection)
        {
            EntityConverterBase <DT, ET, RT, TT> converter = EntityConverterBase <DT, ET, RT, TT> .CreateConverterInstance();

            TT        result    = Activator.CreateInstance <TT>();
            DataTable dataTable = result as DataTable;

            foreach (ET entity in entityCollection)
            {
                dataTable.Rows.Add(converter.ToDataRowImpl(entity, result) as DataRow);
            }

            return(result);
        }
Beispiel #5
0
 /// <summary>
 /// Converts data table to an entity collection.
 /// </summary>
 /// <param name="table">A data table containing data rows.</param>
 /// <returns>The collection of entity objects converted from data rows.</returns>
 public static IList <ET> FromDataTable(TT table)
 {
     return(EntityConverterBase <DT, ET, RT, TT> .FromDataTable(table.Rows));
 }