Exemplo n.º 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);
 }
Exemplo n.º 2
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;
    }
Exemplo n.º 3
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));
      }
    }
Exemplo n.º 4
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)
 {
 }