Defines the interface that a EPiServer Common Entity Provider must adhere to.

Namespace:  EPiServer.Common.Data
Assembly:  EPiServer.Common.Data (in EPiServer.Common.Data.dll) Version: 4.1.517.380

Syntax

C#
public interface IEntityProvider

Remarks

The implementor must, in addition to the interface methods, also provide a method with the following definition: public static EPiServer.Common.Data.IEntityProvider GetProviderInstance()

Examples

The example code below demonstrates how to create an entity provider.
CopyC#
public class SampleEntityProvider : EPiServer.Common.Data.IEntityProvider
{
    private static readonly SampleEntityProvider m_sampleEntityProvider =
        new SampleEntityProvider();

    public static EPiServer.Common.Data.IEntityProvider GetProviderInstance()
    {
        return m_sampleEntityProvider;        
    }

#region IEntityProvider Members
    public object GetEntityInstance(Type type, DbDataReader reader)
    {
        if (type == typeof(Sample))
            return new Sample(reader);
        else
            throw new NotSupportedException(String.Format("The type '{0}' is not supported by this provider.", type.ToString()));
    }

    public object GetEntityInstance(Type type, int id)
    {
        if (type == typeof(Sample))
            return SampleHandler.GetSample(id);
        else
            throw new NotSupportedException(String.Format("The type '{0}' is not supported by this provider.", type.ToString()));
    }
#endregion
}

See Also