CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of DataReader
C#
namespace DataFieldMappingConsoleSample
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
 
    class Program
    {
61 Views
no comments
 
C#
namespace DataFieldMappingConsoleSample
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Linq;
    using System.Reflection;
 
    [AttributeUsage(AttributeTargets.Property)]
51 Views
no comments
 
C#
public static IList<T> ToList<T>(this System.Data.SqlClient.SqlDataReader dr) where T : new()
       {
           Type type = typeof(T);
           if(System.Web.HttpContext.Current.Cache[type.Name + "_properties"] == null)
           {
               System.Web.HttpContext.Current.Cache.Insert(type.Name + "_properties", type.GetProperties().ToList());
           }
           IList<PropertyInfo> properties = (IList<PropertyInfo>)System.Web.HttpContext.Current.Cache[type.Name + "_properties"];
           IList<T> result = new List<T>();
           while(dr.Read())
by ofer   September 25, 2011 @ 3:18am
168 Views
no comments
 
C#
/// <summary>
/// Creates a list of a given type from all the rows in a DataReader.
/// 
/// Note this method uses Reflection so this isn't a high performance
/// operation, but it can be useful for generic data reader to entity
/// conversions on the fly and with anonymous types.
/// </summary>
/// <typeparam name="TType"></typeparam>
/// <param name="reader">An open DataReader that's in position to read</param>
/// <param name="fieldsToSkip">Optional - comma delimited list of fields that you don't want to update</param>
by Rick Strahl   September 23, 2011 @ 3:26pm
825 Views
no comments
 
C#
using(OleDbConnection connection = new OleDbConnection(ConnectionString))
{
    using(OleDbCommand cmd = new OleDbCommand(sql, connection) { CommandType = CommandType.Text })
    { 
        try
        {
            connection.Open();
        }
        catch (OleDbException ex)
        {
by dereklawless   February 12, 2010 @ 6:25pm
187 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate