PersistenceProperty.cs :  » Persistence-Frameworks » Data-Holder » DataHolder » DataPersistence » DBAProvider » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » Data Holder 
Data Holder » DataHolder » DataPersistence » DBAProvider » PersistenceProperty.cs
/*
 * Namespace Summary
 * Copyright (C) 2005+ Bogdan Damian Constantin
 * E-Mail: damianbcpetro@gmail.com
 * WEB: http://www.sourceforge.net/projects/dataholder
 *
 * 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;
using DataHolder.DataPersistence.DBAProvider.Properties;

namespace DataHolder.DataPersistence.DBAProvider{
  /// <summary>
  /// Summary description for DBAGenericDataProperty.  DBAGenericDataPropertiesHolder
  /// </summary>
  public class PersistenceProperty
  {
    public PersistenceProperty(DBDataSource lDBDataSource, PersistenceFieldCollection lPersistenceFieldCollection, UpdateRowSource _UpdatedRowSource)
    {
      this.l_DBDataSource = lDBDataSource;
      this.l_PersistenceFieldCollection = lPersistenceFieldCollection;
      this.l_UpdatedRowSource = _UpdatedRowSource;
    }

    public PersistenceProperty(DBDataSource lDBDataSource, Type DataType, UpdateRowSource _UpdatedRowSource)
    {
      DataHolder.Containers.Property.PropertyCollection pc = DataHolder.Containers.GenericData.TCollection.GetProperties(DataType);
      l_PersistenceFieldCollection = new PersistenceFieldCollection();
      foreach(DataHolder.Containers.Property.GenericDataProperty prop in pc)
        if(prop is DataHolder.Containers.Property.Property)
          l_PersistenceFieldCollection.Add(new TablePersistenceField(prop.PropertyName, 0,prop.PropertyName, null) );
      this.l_DBDataSource = lDBDataSource;
      this.l_UpdatedRowSource = _UpdatedRowSource;
    }

    public PersistenceProperty(DBDataSource lDBDataSource, PersistenceFieldCollection lPersistenceFieldCollection):this(lDBDataSource, lPersistenceFieldCollection, UpdateRowSource.FirstReturnedRecord)
    {
      this.l_DBDataSource = lDBDataSource;
      this.l_PersistenceFieldCollection = lPersistenceFieldCollection;
    }

    protected DBDataSource l_DBDataSource;
    public DBDataSource DBDataSource
    {
      get
      {
        return l_DBDataSource;
      }
    }

    protected PersistenceFieldCollection l_PersistenceFieldCollection;
    public PersistenceFieldCollection PersistenceFieldCollection
    {
      get
      {
        return l_PersistenceFieldCollection;
      }
    }

    protected UpdateRowSource l_UpdatedRowSource;
    public UpdateRowSource UpdatedRowSource
    {
      get
      {
        return l_UpdatedRowSource;
      }
    }

    public int [] GetSelectColumnMapping(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.PersistenceFieldCollection.IndexOfPropertyColumn(ge.Properties[i].PropertyName);
          if(mapIndex >= 0)
            CacheColumnIndex[i] = dr.GetOrdinal(this.PersistenceFieldCollection[mapIndex].RecordSetName);
        }
      }
      return CacheColumnIndex;
    }

    public int [] GetSaveColumnMapping(Containers.GenericData ge, IDataParameterCollection paramcoll)
    {
      int [] CacheColumnIndex = new int[paramcoll.Count];
      for(int i = 0; i < paramcoll.Count; i++)
      {
        IDataParameter param = (IDataParameter)paramcoll[i];
        int index = ge.Properties.IndexOf(param.SourceColumn);        
        if(ge.Properties[index] is Interfaces.IDBGenericProperty)
          CacheColumnIndex[i] = index;
        else if(param.Direction == ParameterDirection.Input
          || param.Direction == ParameterDirection.InputOutput)
          throw new Exception( param.SourceColumn + " source column not found for parameter" + param.ParameterName + " in type " + ge.GetType().FullName);
      }
      return CacheColumnIndex;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.