Exemple #1
0
 public static TableLink LoadTableLink(IDataLayer dbConnection, IPrimaryKeyCreator primaryKeyCreator,
   FieldBlank[] fields, IndexBlank[] indicies,
   string database, string select, string conditionWithoutWhere, params DbParameter[] conditionParameters)
 {
   return LoadTableLink(dbConnection, primaryKeyCreator, fields, indicies, new LinkConstraint[0],
     database, select, conditionWithoutWhere, conditionParameters);
 }
 public MaxPrimaryKeyCreator(IDataLayer dbConnection, string database, 
   string tableName, string fieldName, FieldBlank<int> primaryKeyField)
 {
   this.dbConnection = dbConnection;
   this.database = database;
   this.tableName = tableName;
   this.fieldName = fieldName;
   this.primaryKeyField = primaryKeyField;
 }
 public StandartPrimaryKeyCreator(IDataLayer dbConnection, string primaryKeyTableName, int reservationStep,
   string tableName, FieldBlank<int> primaryKeyField)
 {
   this.dbConnection = dbConnection;
   this.primaryKeyTableName = primaryKeyTableName;
   this.reservationStep = reservationStep;
   this.tableName = tableName;
   this.primaryKeyField = primaryKeyField;
 }
Exemple #4
0
 public static TableLink Load(IDataLayer dbConnection, FieldBlank[] fields, IndexBlank[] indices,
   string database, string select, string conditionWithoutWhere, params DbParameter[] conditionParameters)
 {
   return new TableLink(
     new ReadonlyTableProvider(
       dbConnection.GetTable(database,
         StringHlp.IsEmpty(conditionWithoutWhere) ? select : string.Format("{0} Where {1}", select, conditionWithoutWhere),
         conditionParameters
       )
     ), null, fields, indices
   );
 }
Exemple #5
0
    public static TableLink LoadTableLink(IDataLayer dbConnection, IPrimaryKeyCreator primaryKeyCreator,
      FieldBlank[] fields, IndexBlank[] indicies, LinkConstraint[] constraints,
      string database, string select, string conditionWithoutWhere, params DbParameter[] conditionParameters)
    {
      TableLink link = new TableLink(
        new DatabaseTableProvider(dbConnection, database, select, conditionWithoutWhere, conditionParameters),
        primaryKeyCreator, fields, indicies, constraints);

      if (primaryKeyCreator != null)
        link.Table.PrimaryKey = new DataColumn[] { link.Table.Columns[0] };

      return link;
    }
Exemple #6
0
    public TableLink(ITableProvider tableProvider, IPrimaryKeyCreator primaryKeyCreator,
      FieldBlank[] fields, IndexBlank[] indicies, params LinkConstraint[] constraints)
    {
      this.tableProvider = tableProvider;

      if (tableProvider.Table.Columns.Count != fields.Length)
        throw new Exception("Ошибка создания TableLink: число колонок таблицы не равно числу полей");

      this.primaryKeyCreator = primaryKeyCreator;
      this.indicies = indicies;
      this.constraints = constraints;

      Dictionary<string, bool> isIndicesPartByName = new Dictionary<string, bool>();
      foreach (IndexBlank index in indicies)
      {
        if (index.IsMultiIndex)
          multiIndicesByName[index.IndexName] = new Dictionary<UniversalKey, List<RowLink>>();
        else
          singleIndicesByName[index.IndexName] = new Dictionary<UniversalKey, RowLink>();

        foreach (string fieldName in index.IndexColumns)
          isIndicesPartByName[fieldName] = true;
          //fieldsByName[fieldName].IsIndicesPart = true;
      }

      int columnIndex = 0;
      foreach (FieldBlank fieldBlank in fields)
      {
        fieldsByName[fieldBlank.FieldName] = new FieldLink(fieldBlank, columnIndex, 
          DictionaryHlp.GetValueOrDefault(isIndicesPartByName, fieldBlank.FieldName));
        columnIndex++;
      }

      foreach (DataRow dataRow in tableProvider.Table.Rows)
      {
        if (dataRow.RowState != DataRowState.Deleted)
          CreateIndexForRow(new RowLink(this, dataRow));
      }
    }
Exemple #7
0
 public TableLink(DataTable table, FieldBlank[] fields, IndexBlank[] indices) :
   this(new ReadonlyTableProvider(table), null, fields, indices)
 {
 }
Exemple #8
0
 public TableLink(IDataLayer dbConnection, string database, DataTable table, string updateQuery, 
   IPrimaryKeyCreator primaryKeyCreator, FieldBlank[] fields, IndexBlank[] indicies, params LinkConstraint[] constraints) :
   this(new DatabaseTableProvider(dbConnection, database, updateQuery, table),
     primaryKeyCreator, fields, indicies, constraints)
 {
 }
Exemple #9
0
 public FieldLink(FieldBlank fieldBlank, int columnIndex, bool isIndicesPart)
 {
   this.FieldBlank = fieldBlank;
   this.ColumnIndex = columnIndex;
   this.IsIndicesPart = isIndicesPart;
 }