Click here to Skip to main content
15,895,557 members
Articles / Programming Languages / C#

Converting a DataSet to a Generic List

Rate me:
Please Sign up or sign in to vote.
4.57/5 (6 votes)
18 Jul 2009CPOL7 min read 77.8K   993   25  
Presents a simple utility framework that helps in converting DataSets to generic Lists.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Citrus.Data.Core
{
    /// <summary>
    /// Implements a simple cached entity definition provider
    /// </summary>
    public class CachedEntityDefinitionProvider : IEntityDefinitionProvider
    {
        /// <summary>
        /// The internal entity type cache
        /// </summary>
        static readonly List<Type> EntityTypes = new List<Type>();

        /// <summary>
        /// Determines if the specified type is an entity type
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public bool IsEntity(Type t)
        {
            // If there are no types to check, we do not know
            // if the type is an entity or not
            if (EntityTypes.Count == 0) return false;

            // If the type is present in our type cache
            // its an entity type
            return EntityTypes.Contains(t);
        }

        /// <summary>
        /// Adds an entity type to the entity cache
        /// </summary>
        /// <param name="entityType"></param>
        public void AddEntityType(Type entityType)
        {
            if (!EntityTypes.Contains(entityType))
                EntityTypes.Add(entityType);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
I work as a Technology Lead for an IT services company based in India.

Passions include programming methodologies, compiler theory, cartooning and calligraphy.

Comments and Discussions