Method LoadDataTypeFromSource
LoadDataTypeFromSource(String, DistributedDataType)
Responsible for loading the list from the data source. Name is passed as a parameter.
Declaration
ProviderDataTypeItem<IEnumerable> LoadDataTypeFromSource(string key, DistributedDataType dataType)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key used to reference the object. |
DistributedDataType | dataType | Type of collection. |
Returns
Type | Description |
---|---|
ProviderDataTypeItem<System.Collections.IEnumerable> | A CacheItem with limited fields. |
Examples
The following example performs operation to load the specified data type from the data source.
public ProviderDataTypeItem<IEnumerable> LoadDataTypeFromSource(string key, DistributedDataType dataType)
{
IEnumerable value = null;
ProviderDataTypeItem<IEnumerable> dataTypeItem = null;
switch (dataType)
{
case DistributedDataType.List:
value = new List<object>()
{
LoadFromDataSource(key)
};
dataTypeItem = new ProviderDataTypeItem<IEnumerable>(value);
break;
case DistributedDataType.Dictionary:
value = new Dictionary<string, object>()
{
{ key , LoadFromDataSource(key) }
};
dataTypeItem = new ProviderDataTypeItem<IEnumerable>(value);
break;
case DistributedDataType.Counter:
dataTypeItem = new ProviderDataTypeItem<IEnumerable>(1000);
break;
}
return dataTypeItem;
}
private object LoadFromDataSource(string key)
{
// Load item from your data source and return retrieved Object
return _source.LoadObject(key);
}