# GrapeCity.ActiveReports.Data.IListDataSource

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="GrapeCity_ActiveReports_Data_IListDataSource" data-uid="GrapeCity.ActiveReports.Data.IListDataSource" class="text-break">IListDataSource Interface
</h1>
  <div class="markdown level0 summary"><p>Wrapper over <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ilist">IList</a> interface to use it as data source: <a class="xref" href="GrapeCity.ActiveReports.SectionReport.DataSource.html#GrapeCity_ActiveReports_SectionReport_DataSource">DataSource</a>.
This should be used only if performance of current implementation is not enough.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <h6><strong>Namespace</strong>: <a class="xref" href="GrapeCity.ActiveReports.Data.html">GrapeCity.ActiveReports.Data</a></h6>
  <h6><strong>Assembly</strong>: MESCIUS.ActiveReports.dll</h6>
  <h5 id="GrapeCity_ActiveReports_Data_IListDataSource_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public interface IListDataSource</code></pre>
  </div>
  <h5 id="GrapeCity_ActiveReports_Data_IListDataSource_examples"><strong>Examples</strong></h5>
  <p>This snippet shows how to implement the interface with <a href="https://www.nuget.org/packages/FastMember.Signed/1.5.0">https://www.nuget.org/packages/FastMember.Signed/1.5.0</a>
Note: <b>Product</b> here is custom business object.</p>
<pre><code class="lang-csharp">class Product
{
	public int ProductID { get; set; }
	public string ProductName { get; set; }
}
class FastListDataSource : IListDataSource
{
	private readonly System.Collections.Generic.IList &lt; Product &gt; _list;
	private readonly System.Data.IDataReader _reader;
	public FastListDataSource(System.Collections.Generic.IList &lt; Product &gt; list)
	{
		_list = list;
		_reader = FastMember.ObjectReader.Create(_list);
	}
	public object GetValue(string fieldName, int ordinal)
	{
		var index = fieldName.IndexOf('.');
		if (index == -1)
			return _reader.GetValue(ordinal);
		var fields = fieldName.Split('.');
		var target = _reader.GetValue(ordinal);
		for (int i = 1; i != fields.Length; i++)
			target = FastMember.ObjectAccessor.Create(target)[fields[i]];
		return target;
	}
	public int GetOrdinal(string fieldName)
	{
		var index = fieldName.IndexOf('.');
		if (index == -1)
			return _reader.GetOrdinal(fieldName);
		return _reader.GetOrdinal(fieldName.Substring(0, index));
	}
	public System.Collections.IList List =&gt; (System.Collections.IList)_list;
	public System.Data.IDataReader DataReader =&gt; _reader;
}</code></pre>

  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_ActiveReports_Data_IListDataSource_DataReader" data-uid="GrapeCity.ActiveReports.Data.IListDataSource.DataReader">
          <a class="xref" href="GrapeCity.ActiveReports.Data.IListDataSource.DataReader.html#GrapeCity_ActiveReports_Data_IListDataSource_DataReader">DataReader</a>
        </td>
        <td class="markdown level1 summary"><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.idatareader">IDataReader</a> to read the data.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_ActiveReports_Data_IListDataSource_List" data-uid="GrapeCity.ActiveReports.Data.IListDataSource.List">
          <a class="xref" href="GrapeCity.ActiveReports.Data.IListDataSource.List.html#GrapeCity_ActiveReports_Data_IListDataSource_List">List</a>
        </td>
        <td class="markdown level1 summary"><p>Wrapped <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ilist">IList</a> instance.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_ActiveReports_Data_IListDataSource_GetOrdinal_System_String_" data-uid="GrapeCity.ActiveReports.Data.IListDataSource.GetOrdinal(System.String)">
          <a class="xref" href="GrapeCity.ActiveReports.Data.IListDataSource.GetOrdinal.html#GrapeCity_ActiveReports_Data_IListDataSource_GetOrdinal_System_String_">GetOrdinal(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Allows to cache ordinal.
Suggested to return <b>0</b> or any valid value for <a class="xref" href="GrapeCity.ActiveReports.Data.IListDataSource.GetValue.html#GrapeCity_ActiveReports_Data_IListDataSource_GetValue_System_String_System_Int32_">GetValue(string, int)</a> method implementation.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_ActiveReports_Data_IListDataSource_GetValue_System_String_System_Int32_" data-uid="GrapeCity.ActiveReports.Data.IListDataSource.GetValue(System.String,System.Int32)">
          <a class="xref" href="GrapeCity.ActiveReports.Data.IListDataSource.GetValue.html#GrapeCity_ActiveReports_Data_IListDataSource_GetValue_System_String_System_Int32_">GetValue(string, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Access to value.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="extensionmethods">Extension Methods</h3>
  <div>
      <a class="xref" href="GrapeCity.ActiveReports.ReportsCore.Tools.ObjectExtensions.ApplyDefaults.html#GrapeCity_ActiveReports_ReportsCore_Tools_ObjectExtensions_ApplyDefaults__1___0_">ObjectExtensions.ApplyDefaults&lt;TObject&gt;(TObject)</a>
  </div>
  <div>
      <a class="xref" href="GrapeCity.ActiveReports.ReportsCore.Tools.ObjectExtensions.SetValue.html#GrapeCity_ActiveReports_ReportsCore_Tools_ObjectExtensions_SetValue__1___0_System_ComponentModel_PropertyDescriptor_System_String_">ObjectExtensions.SetValue&lt;TObject&gt;(TObject, PropertyDescriptor, string)</a>
  </div>
  <div>
      <a class="xref" href="GrapeCity.ActiveReports.ReportsCore.Tools.ObjectExtensions.ToNameValueCollection.html#GrapeCity_ActiveReports_ReportsCore_Tools_ObjectExtensions_ToNameValueCollection_System_Object_">ObjectExtensions.ToNameValueCollection(object)</a>
  </div>

</div>
