/*
* Namespace Summary
* Copyright (C) 2005 Bogdan Damian Constantin
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License 2.1 or later, as
* published by the Free Software Foundation. See the included License.txt
* or http://www.gnu.org/copyleft/lesser.html for details.
*
*/
using System;
using System.Data;
using System.Data.Common;
namespace DataHolder.DataPersistence.DBAProvider{
/// <summary>
/// Summary description for DBAGenericDataProperty. DBAGenericDataPropertiesHolder
/// </summary>
public class PersistenceProperty
{
public PersistenceProperty(string lFromClause, PersistanceColumnMappingCollection lPersistanceColumnMappingCollection, UpdateRowSource _UpdatedRowSource)
{
this.l_FromClause = lFromClause;
this.l_PersistanceColumnMappingCollection = lPersistanceColumnMappingCollection;
this.l_UpdatedRowSource = _UpdatedRowSource;
}
public PersistenceProperty(string lFromClause, Type DataType, UpdateRowSource _UpdatedRowSource)
{
DataHolder.Containers.Property.PropertyCollection pc = DataHolder.Containers.GenericData.TCollection.GetProperties(DataType);
l_PersistanceColumnMappingCollection = new PersistanceColumnMappingCollection();
foreach(DataHolder.Containers.Property.GenericDataProperty prop in pc)
if(prop is DataHolder.Containers.Property.Property)
l_PersistanceColumnMappingCollection.Add(prop.PropertyName,prop.PropertyName);
this.l_FromClause = lFromClause;
this.l_UpdatedRowSource = _UpdatedRowSource;
}
public PersistenceProperty(string lFromClause, PersistanceColumnMappingCollection lPersistanceColumnMappingCollection):this(lFromClause, lPersistanceColumnMappingCollection, UpdateRowSource.FirstReturnedRecord)
{
this.l_FromClause = lFromClause;
this.l_PersistanceColumnMappingCollection = lPersistanceColumnMappingCollection;
}
protected string l_FromClause;
public string FromClause
{
get
{
return l_FromClause;
}
}
protected PersistanceColumnMappingCollection l_PersistanceColumnMappingCollection;
public PersistanceColumnMappingCollection PersistanceColumnMappingCollection
{
get
{
return l_PersistanceColumnMappingCollection;
}
}
protected UpdateRowSource l_UpdatedRowSource;
public UpdateRowSource UpdatedRowSource
{
get
{
return l_UpdatedRowSource;
}
}
public int [] GetColumnMapping(Containers.GenericData ge, IDataReader dr)
{
int [] CacheColumnIndex = new int[ge.Properties.Count];
for(int i = 0; i < ge.Properties.Count; i++)
{
CacheColumnIndex[i] = -1;
if(ge.Properties[i] is Interfaces.IDBGenericProperty)
{
int mapIndex = this.PersistanceColumnMappingCollection.IndexOfPropertyColumn(ge.Properties[i].PropertyName);
if(mapIndex >= 0)
CacheColumnIndex[i] = dr.GetOrdinal(this.PersistanceColumnMappingCollection[mapIndex].RecordSetName);
}
}
return CacheColumnIndex;
}
public int [] GetColumnMapping(Containers.GenericData ge, IDataParameterCollection paramcoll)
{
int [] CacheColumnIndex = new int[ge.Properties.Count];
for(int i = 0; i < ge.Properties.Count; i++)
{
CacheColumnIndex[i] = -1;
if(ge.Properties[i] is Interfaces.IDBGenericProperty)
{
for(int pcount = 0; pcount < paramcoll.Count; pcount++)
if(((IDataParameter)paramcoll[pcount]).SourceColumn == ge.Properties[i].PropertyName)
CacheColumnIndex[i] = pcount;
}
}
return CacheColumnIndex;
}
}
}
|