E
Elliott810
I have to be honest I haven't used many generics in my coding; I
really want to start using more of them but am having trouble with
what is the best way to use a generic with my Send method because the
Send method needs to point to different data factories. I really would
like to hear some suggestions.
using System;
using System.Collections;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Xml;
namespace PartsNow.Site.Database.Data
{
public class Groups
{
#region Fields
ArrayList m_items = new ArrayList();
#endregion
#region Properties
public virtual Group this[int index]
{
get
{
return (Group)m_items[index];
}
}
#endregion
#region Constructors
public Groups(Group[] objs)
{
foreach (Group obj in objs)
{
this.List.Add(obj);
}
}
internal Groups(SqlDataReader dbReader)
{
while (dbReader.Read())
{
m_items.Add(new Group(dbReader));
}
}
#endregion
#region Methods
public virtual void Add(Group obj)
{
this.List.Add(obj);
}
public virtual Group[] ToArray()
{
return (Group[])m_items.ToArray(typeof(Group));
}
public void Send()
{
SqlDataRecord dbRecord = new
SqlDataRecord(Factory.Catalog.MetaData);
SqlContext.Pipe.SendResultsStart(dbRecord);
foreach (Catalog catalog in base.List)
{
Factory.Catalog.SendResultsRow(catalog, dbRecord);
}
SqlContext.Pipe.SendResultsEnd();
}
#endregion
}
}
really want to start using more of them but am having trouble with
what is the best way to use a generic with my Send method because the
Send method needs to point to different data factories. I really would
like to hear some suggestions.
using System;
using System.Collections;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Xml;
namespace PartsNow.Site.Database.Data
{
public class Groups
{
#region Fields
ArrayList m_items = new ArrayList();
#endregion
#region Properties
public virtual Group this[int index]
{
get
{
return (Group)m_items[index];
}
}
#endregion
#region Constructors
public Groups(Group[] objs)
{
foreach (Group obj in objs)
{
this.List.Add(obj);
}
}
internal Groups(SqlDataReader dbReader)
{
while (dbReader.Read())
{
m_items.Add(new Group(dbReader));
}
}
#endregion
#region Methods
public virtual void Add(Group obj)
{
this.List.Add(obj);
}
public virtual Group[] ToArray()
{
return (Group[])m_items.ToArray(typeof(Group));
}
public void Send()
{
SqlDataRecord dbRecord = new
SqlDataRecord(Factory.Catalog.MetaData);
SqlContext.Pipe.SendResultsStart(dbRecord);
foreach (Catalog catalog in base.List)
{
Factory.Catalog.SendResultsRow(catalog, dbRecord);
}
SqlContext.Pipe.SendResultsEnd();
}
#endregion
}
}