Format:
Recent snippets matching tags of DataReader
namespace DataFieldMappingConsoleSample { using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; class Program {
61 Views
no comments
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
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())
168 Views
no comments
/// <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>
825 Views
no comments
using(OleDbConnection connection = new OleDbConnection(ConnectionString)) { using(OleDbCommand cmd = new OleDbCommand(sql, connection) { CommandType = CommandType.Text }) { try { connection.Open(); } catch (OleDbException ex) {
187 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
