Ejemplo n.º 1
0
 /// <summary>
 ///   Instantiates a new instance of the <c>Parameter</c> module.
 /// </summary>
 public ParameterInfo()
 {
     Key = new UniqueKey();
     Type = ParameterType.StaticValue.ToString();
     IsValueRequired = false;
     TypeArgument = "";
 }
Ejemplo n.º 2
0
        public void BatchInsertingExistingKeyThrows()
        {
            var updateStrategy = new UniqueKey<string, string>();
            using (var blocks = CreateBlocks(true))
            {
                var gist = CreateGist(blocks, updateStrategy);

                gist.Insert("A", "value for A");

                Assert.Throws<DuplicateKeyException>(() => gist.Insert("A", "new value for A"));
            }
        }
Ejemplo n.º 3
0
        public override Dictionary<Index, List<DataField>> GetIndexes(string tableName)
        {
            Dictionary<Index, List<DataField>> indexes = new Dictionary<Index, List<DataField>>(4);

            DataTable fieldTable = SelectQuery(string.Format("SHOW INDEXES FROM `{0}`",
                Mysql.Escape(tableName)));

            foreach (DataRow dr in fieldTable.Rows)
            {
                DataField df = new DataField((string)dr["Table"], (string)dr["Column_name"]);
                string key = (string)dr["Key_name"];

                Index index = null;

                if ((long)dr["Non_unique"] == 0)
                {
                    if (key == "PRIMARY")
                    {
                        index = new PrimaryKey();
                    }
                    else
                    {
                        index = new UniqueKey(key);
                    }
                }
                else
                {
                    index = new Index(key);
                }

                if (indexes.ContainsKey(index) == false)
                {
                    indexes.Add(index, new List<DataField>());
                }

                indexes[index].Add(df);
            }

            return indexes;
        }
Ejemplo n.º 4
0
        protected override IEnumerable<IDataParameter> CoreGetUniqueKeyColumnParameters(IUnitOfWorkContext unitOfWorkContext, string dataSourceTag, Database database, Schema schema, Table table, UniqueKey uniqueKey)
        {
            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)dataSourceTag == null)
                throw new ArgumentNullException("dataSourceTag");

            if ((object)database == null)
                throw new ArgumentNullException("database");

            if ((object)schema == null)
                throw new ArgumentNullException("schema");

            if ((object)table == null)
                throw new ArgumentNullException("table");

            if ((object)uniqueKey == null)
                throw new ArgumentNullException("uniqueKey");

            if (dataSourceTag.SafeToString().ToLower() == "odbc.sqlserver")
            {
                return new IDataParameter[]
                       {
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P1", schema.SchemaName),
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P2", table.TableName),
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P3", uniqueKey.UniqueKeyName)
                       };
            }
            else if (dataSourceTag.SafeToString().ToLower() == "odbc.sybaseiq")
            {
                return new IDataParameter[]
                       {
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P1", schema.SchemaName),
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P2", table.TableName),
                           unitOfWorkContext.CreateParameter(ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P3", uniqueKey.UniqueKeyName)
                       };
            }

            throw new ArgumentOutOfRangeException(string.Format("dataSourceTag: '{0}'", dataSourceTag));
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ParentObjectParameterSet, StringComparison.Ordinal))
            {
                ResourceIdentifier resourceIdentifier = new ResourceIdentifier(InputObject.Id);
                ResourceGroupName = resourceIdentifier.ResourceGroupName;
                DatabaseName      = resourceIdentifier.ResourceName;
                AccountName       = ResourceIdentifierExtensions.GetDatabaseAccountName(resourceIdentifier);
            }

            List <string> Paths = new List <string>();

            foreach (string path in PartitionKeyPath)
            {
                Paths.Add(path);
            }

            SqlContainerResource sqlContainerResource = new SqlContainerResource
            {
                Id           = Name,
                PartitionKey = new ContainerPartitionKey
                {
                    Kind    = PartitionKeyKind,
                    Paths   = Paths,
                    Version = PartitionKeyVersion
                }
            };

            if (UniqueKeyPolicy != null)
            {
                UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy
                {
                    UniqueKeys = new List <UniqueKey>()
                };

                foreach (PSUniqueKey uniqueKey in UniqueKeyPolicy.UniqueKeys)
                {
                    UniqueKey key = new UniqueKey
                    {
                        Paths = new List <string>()
                    };

                    foreach (string path in uniqueKey.Paths)
                    {
                        key.Paths.Add(path);
                    }

                    uniqueKeyPolicy.UniqueKeys.Add(key);
                }

                sqlContainerResource.UniqueKeyPolicy = uniqueKeyPolicy;
            }

            if (TtlInSeconds != null)
            {
                sqlContainerResource.DefaultTtl = TtlInSeconds;
            }

            if (ConflictResolutionPolicy != null)
            {
                ConflictResolutionPolicyMode = ConflictResolutionPolicy.Mode;

                if (ConflictResolutionPolicy.ConflictResolutionPath != null)
                {
                    ConflictResolutionPolicyPath = ConflictResolutionPolicy.ConflictResolutionPath;
                }

                if (ConflictResolutionPolicy.ConflictResolutionProcedure != null)
                {
                    ConflictResolutionPolicyProcedure = ConflictResolutionPolicy.ConflictResolutionProcedure;
                }
            }

            if (ConflictResolutionPolicyMode != null)
            {
                ConflictResolutionPolicy conflictResolutionPolicy = new ConflictResolutionPolicy
                {
                    Mode = ConflictResolutionPolicyMode
                };

                if (ConflictResolutionPolicyMode.Equals("LastWriterWins", StringComparison.OrdinalIgnoreCase))
                {
                    conflictResolutionPolicy.ConflictResolutionPath = ConflictResolutionPolicyPath;
                }
                else if (ConflictResolutionPolicyMode.Equals("Custom", StringComparison.OrdinalIgnoreCase))
                {
                    conflictResolutionPolicy.ConflictResolutionProcedure = ConflictResolutionPolicyProcedure;
                }

                sqlContainerResource.ConflictResolutionPolicy = conflictResolutionPolicy;
            }

            if (IndexingPolicy != null)
            {
                IndexingPolicy indexingPolicy = new IndexingPolicy
                {
                    Automatic    = IndexingPolicy.Automatic,
                    IndexingMode = IndexingPolicy.IndexingMode,
                };

                if (IndexingPolicy.IncludedPaths != null)
                {
                    IList <IncludedPath> includedPaths = new List <IncludedPath>();
                    foreach (PSIncludedPath pSIncludedPath in IndexingPolicy.IncludedPaths)
                    {
                        includedPaths.Add(new IncludedPath
                        {
                            Path    = pSIncludedPath.Path,
                            Indexes = PSIncludedPath.ConvertPSIndexesToIndexes(pSIncludedPath.Indexes)
                        });
                    }

                    indexingPolicy.IncludedPaths = new List <IncludedPath>(includedPaths);
                }

                if (IndexingPolicy.ExcludedPaths != null && IndexingPolicy.ExcludedPaths.Count > 0)
                {
                    IList <ExcludedPath> excludedPaths = new List <ExcludedPath>();
                    foreach (PSExcludedPath pSExcludedPath in IndexingPolicy.ExcludedPaths)
                    {
                        excludedPaths.Add(new ExcludedPath {
                            Path = pSExcludedPath.Path
                        });
                    }

                    indexingPolicy.ExcludedPaths = new List <ExcludedPath>(excludedPaths);
                }

                if (IndexingPolicy.CompositeIndexes != null)
                {
                    IList <IList <CompositePath> > compositeIndexes = new List <IList <CompositePath> >();
                    foreach (IList <PSCompositePath> pSCompositePathList in IndexingPolicy.CompositeIndexes)
                    {
                        IList <CompositePath> compositePathList = new List <CompositePath>();
                        foreach (PSCompositePath pSCompositePath in pSCompositePathList)
                        {
                            compositePathList.Add(new CompositePath {
                                Order = pSCompositePath.Order, Path = pSCompositePath.Path
                            });
                        }

                        compositeIndexes.Add(compositePathList);
                    }

                    indexingPolicy.CompositeIndexes = new List <IList <CompositePath> >(compositeIndexes);
                }

                if (IndexingPolicy.SpatialIndexes != null && IndexingPolicy.SpatialIndexes.Count > 0)
                {
                    IList <SpatialSpec> spatialIndexes = new List <SpatialSpec>();

                    foreach (PSSpatialSpec pSSpatialSpec in IndexingPolicy.SpatialIndexes)
                    {
                        spatialIndexes.Add(new SpatialSpec {
                            Path = pSSpatialSpec.Path, Types = pSSpatialSpec.Types
                        });
                    }

                    indexingPolicy.SpatialIndexes = new List <SpatialSpec>(spatialIndexes);
                }

                sqlContainerResource.IndexingPolicy = indexingPolicy;
            }

            IDictionary <string, string> options = new Dictionary <string, string>();

            if (Throughput != null)
            {
                options.Add("Throughput", Throughput.ToString());
            }

            SqlContainerCreateUpdateParameters sqlContainerCreateUpdateParameters = new SqlContainerCreateUpdateParameters
            {
                Resource = sqlContainerResource,
                Options  = options
            };

            if (ShouldProcess(Name, "Setting CosmosDB Sql Container"))
            {
                SqlContainerGetResults sqlContainerGetResults = CosmosDBManagementClient.SqlResources.CreateUpdateSqlContainerWithHttpMessagesAsync(ResourceGroupName, AccountName, DatabaseName, Name, sqlContainerCreateUpdateParameters).GetAwaiter().GetResult().Body;
                WriteObject(new PSSqlContainerGetResults(sqlContainerGetResults));
            }

            return;
        }
Ejemplo n.º 6
0
 public void UniqueKeyKeyExtGrainCategoryDisallowsEmptyKeyExtension()
 {
     UniqueKey.NewKey(Guid.NewGuid(), category: UniqueKey.Category.KeyExtGrain, keyExt: "");
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new grain and a grain reference pair.
 /// </summary>
 /// <param name="grainId">The grain ID.</param>
 /// <param name="version">The initial version of the state.</param>
 /// <returns>A grain reference and a state pair.</returns>
 internal static Tuple <GrainReference, GrainState <TestState1> > GetTestReferenceAndState(long grainId, string version)
 {
     return(Tuple.Create(GrainReference.FromGrainId(GrainId.GetGrainId(UniqueKey.NewKey(grainId, UniqueKey.Category.Grain))), new GrainState <TestState1> {
         State = new TestState1(), ETag = version
     }));
 }
Ejemplo n.º 8
0
        /// <summary> Read an <c>ActivationId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal static ActivationId ReadActivationId(this IBinaryTokenStreamReader @this)
        {
            UniqueKey key = @this.ReadUniqueKey();

            return(ActivationId.GetActivationId(key));
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox2.Items.Count == 0)
            {
                MessageBox.Show("You need to select a database.");
                return;
            }
            if (string.IsNullOrEmpty(txtTBName.Text.Replace(" ", "")))
            {
                MessageBox.Show("You need to insert a table name");
                return;
            }
            if (dataGridView1.Rows.Count <= 1)
            {
                MessageBox.Show("You need to add a column at least.");
                return;
            }
            List <Database> list = DataLayer.Configuration.GetAllData();

            foreach (var item in listBox2.Items)
            {
                if (list.FirstOrDefault(x => x.DatabaseName == item.ToString()).Tables.Count(x => x.TableName == txtTBName.Text) > 0)
                {
                    MessageBox.Show("There already exists a table with this name!");
                    return;
                }
            }
            Table table = new Table();

            table.TableName = txtTBName.Text;
            List <Column>     columns = new List <Column>();
            List <PrimaryKey> pklist  = new List <PrimaryKey>();
            List <UniqueKey>  ukList  = new List <UniqueKey>();
            List <ForeignKey> fkList  = new List <ForeignKey>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                Column column = new Column();
                if (row.Cells[0].Value != null)
                {
                    if (!string.IsNullOrEmpty(row.Cells[0].Value.ToString()))
                    {
                        column.ColumnName = row.Cells[0].Value.ToString();
                    }
                }
                if (row.Cells[1].Value != null)
                {
                    if (!string.IsNullOrEmpty(row.Cells[1].Value.ToString()))
                    {
                        column.Type = row.Cells[1].Value.ToString();
                    }
                }
                if (row.Cells[2].Value != null)
                {
                    column.IsNull = Utils.Utilities.GetBoolFromString(row.Cells[2].Value.ToString());
                }
                if (!string.IsNullOrEmpty(column.ColumnName) && !string.IsNullOrEmpty(column.Type))
                {
                    columns.Add(column);
                }
                if (row.Cells[3].Value != null)
                {
                    int parse = 0;
                    Int32.TryParse(row.Cells[3].Value.ToString(), out parse);
                    if (parse != 0)
                    {
                        column.Length = parse;
                    }
                }
                PrimaryKey pk = new PrimaryKey();
                if (row.Cells[4].Value != null && Utils.Utilities.GetBoolFromString(row.Cells[4].Value.ToString()))
                {
                    pk.Key = row.Cells[0].Value.ToString();
                    pklist.Add(pk);
                }
                UniqueKey uk = new UniqueKey();
                if (row.Cells[5].Value != null && Utils.Utilities.GetBoolFromString(row.Cells[5].Value.ToString()))
                {
                    uk.Key = row.Cells[0].Value.ToString();
                    ukList.Add(uk);
                }
                ForeignKey fKey = new ForeignKey();
                if (row.Cells[6].Value != null)
                {
                    fKey.Key = row.Cells[0].Value.ToString();
                    string[] key = Utils.Utilities.Split(row.Cells[6].Value.ToString());
                    fKey.RefTable     = key[0];
                    fKey.RefAttribute = key[1];
                    fkList.Add(fKey);
                }
            }
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                PrimaryKey pk = new PrimaryKey();
                if (row.Cells[3].Value != null)
                {
                    pk.Key = row.Cells[0].Value.ToString();
                }
            }
            table.PrimaryKey = pklist;
            table.UniqueKey  = ukList;
            table.ForeignKey = fkList;
            table.Columns    = columns;

            List <Database> dbs = new List <Database>();

            foreach (var item in listBox2.Items)
            {
                Database d = new Database();
                if (item != null)
                {
                    d.DatabaseName = item.ToString();
                }
                d.Tables = new List <Table>();
                d.Tables.Add(table);
                dbs.Add(d);
            }
            DataLayer.Configuration.AddTable(dbs);
            MessageBox.Show("Table " + table.TableName + " created successfully!");
        }
Ejemplo n.º 10
0
 public void FromRngFixedLenght()
 {
     CheckRandomGenerated(UniqueKey.FromRandomNumberGeneratedComplex(), 12);
 }
Ejemplo n.º 11
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ParentObjectParameterSet, StringComparison.Ordinal))
            {
                ResourceIdentifier resourceIdentifier = new ResourceIdentifier(InputObject.Id);
                ResourceGroupName = resourceIdentifier.ResourceGroupName;
                DatabaseName      = resourceIdentifier.ResourceName;
                AccountName       = ResourceIdentifierExtensions.GetDatabaseAccountName(resourceIdentifier);
            }

            List <string> Paths = new List <string>();

            foreach (string path in PartitionKeyPath)
            {
                Paths.Add(path);
            }

            SqlContainerResource sqlContainerResource = new SqlContainerResource
            {
                Id           = Name,
                PartitionKey = new ContainerPartitionKey
                {
                    Kind    = PartitionKeyKind,
                    Paths   = Paths,
                    Version = PartitionKeyVersion
                }
            };

            if (UniqueKeyPolicy != null)
            {
                UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy();

                foreach (PSSqlUniqueKey uniqueKey in UniqueKeyPolicy.UniqueKey)
                {
                    UniqueKey key = new UniqueKey(uniqueKey.Path);
                    uniqueKeyPolicy.UniqueKeys.Add(key);
                }

                sqlContainerResource.UniqueKeyPolicy = uniqueKeyPolicy;
            }

            if (TtlInSeconds != null)
            {
                sqlContainerResource.DefaultTtl = TtlInSeconds;
            }

            if (ConflictResolutionPolicy != null)
            {
                ConflictResolutionPolicy conflictResolutionPolicy = new ConflictResolutionPolicy
                {
                    Mode = ConflictResolutionPolicy.Type
                };

                if (ConflictResolutionPolicy.Type.Equals("LastWriterWins", StringComparison.OrdinalIgnoreCase))
                {
                    conflictResolutionPolicy.ConflictResolutionPath = ConflictResolutionPolicy.Path;
                }
                else if (ConflictResolutionPolicy.Type.Equals("Custom", StringComparison.OrdinalIgnoreCase))
                {
                    conflictResolutionPolicy.ConflictResolutionProcedure = ConflictResolutionPolicy.ConflictResolutionProcedure;
                }

                sqlContainerResource.ConflictResolutionPolicy = conflictResolutionPolicy;
            }

            if (IndexingPolicy != null)
            {
                IList <IncludedPath> includedPaths = new List <IncludedPath>();
                IList <ExcludedPath> excludedPaths = new List <ExcludedPath>();

                foreach (string path in IndexingPolicy.IncludedPaths)
                {
                    includedPaths.Add(new IncludedPath(path: path));
                }

                foreach (string path in IndexingPolicy.ExcludedPaths)
                {
                    excludedPaths.Add(new ExcludedPath(path: path));
                }

                IndexingPolicy indexingPolicy = new IndexingPolicy
                {
                    Automatic     = IndexingPolicy.Automatic,
                    IndexingMode  = IndexingPolicy.IndexingMode,
                    IncludedPaths = includedPaths,
                    ExcludedPaths = excludedPaths
                };

                sqlContainerResource.IndexingPolicy = indexingPolicy;
            }

            IDictionary <string, string> options = new Dictionary <string, string>();

            if (Throughput != null)
            {
                options.Add("Throughput", Throughput.ToString());
            }

            SqlContainerCreateUpdateParameters sqlContainerCreateUpdateParameters = new SqlContainerCreateUpdateParameters
            {
                Resource = sqlContainerResource,
                Options  = options
            };

            if (ShouldProcess(Name, "Creating or Updating CosmosDB Sql Container"))
            {
                SqlContainerGetResults sqlContainerGetResults = CosmosDBManagementClient.SqlResources.CreateUpdateSqlContainerWithHttpMessagesAsync(ResourceGroupName, AccountName, DatabaseName, Name, sqlContainerCreateUpdateParameters).GetAwaiter().GetResult().Body;
                WriteObject(new PSSqlContainerGetResults(sqlContainerGetResults));
            }

            return;
        }
Ejemplo n.º 12
0
 private UniqueKey getUniqueKey(string path)
 {
     var key = new UniqueKey();
     key.Paths.Add(path);
     return key;
 }
Ejemplo n.º 13
0
 public override int GetHashCode()
 {
     return(UniqueKey.GetHashCode());
 }
Ejemplo n.º 14
0
 public void UniqueKeyKeyExtGrainCategoryDisallowsWhiteSpaceKeyExtension()
 {
     Xunit.Assert.Throws <ArgumentException>(() =>
                                             UniqueKey.NewKey(Guid.NewGuid(), category: UniqueKey.Category.KeyExtGrain, keyExt: " \t\n\r"));
 }
Ejemplo n.º 15
0
 public void UniqueKeyKeyExtGrainCategoryDisallowsNullKeyExtension()
 {
     Xunit.Assert.Throws <ArgumentNullException>(() =>
                                                 UniqueKey.NewKey(Guid.NewGuid(), category: UniqueKey.Category.KeyExtGrain, keyExt: null));
 }
Ejemplo n.º 16
0
 internal void Write(UniqueKey key)
 {
     Write(key.N0);
     Write(key.N1);
     Write(key.TypeCodeData);
     Write(key.KeyExt);
 }
Ejemplo n.º 17
0
        protected override IEnumerable <DbParameter> CoreGetUniqueKeyColumnParameters(Type connectionType, string dataSourceTag, Server server, Database database, Schema schema, Table table, UniqueKey uniqueKey)
        {
            if ((object)connectionType == null)
            {
                throw new ArgumentNullException(nameof(connectionType));
            }

            if ((object)dataSourceTag == null)
            {
                throw new ArgumentNullException(nameof(dataSourceTag));
            }

            if ((object)server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            if ((object)database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

            if ((object)schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }

            if ((object)table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            if ((object)uniqueKey == null)
            {
                throw new ArgumentNullException(nameof(uniqueKey));
            }

            if (dataSourceTag.SafeToString().ToLower() == ODBC_SQL_SERVER_DATA_SOURCE_TAG)
            {
                return(new DbParameter[]
                {
                    //SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P1", server.ServerName),
                    //SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P2", database.DatabaseName),
                    SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(connectionType, null, ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P3", schema.SchemaName),
                    //SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P4", table.TableName),
                    SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(connectionType, null, ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P5", uniqueKey.UniqueKeyName)
                });
            }

            throw new ArgumentOutOfRangeException(string.Format("dataSourceTag: '{0}'", dataSourceTag));
        }
Ejemplo n.º 18
0
        /// <summary> Read an <c>GrainId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal GrainId ReadGrainId()
        {
            UniqueKey key = ReadUniqueKey();

            return(GrainId.GetGrainId(key));
        }
Ejemplo n.º 19
0
        private void LoadDatabaseSchema(DataSet ds)
        {
            DataRowCollection drs;

            Table      table;
            View       view;
            Procedure  procedure;
            ForeignKey foreignKey;
            UniqueKey  uniqueKey;
            DbType     dbType;
            string     specificDbType;
            string     constraintName;
            string     columnName;
            string     key;

            #region [0] Tables

            drs = ds.Tables[0].Rows;

            foreach (DataRow dr in drs)
            {
                this.database.Tables.Add(
                    new Table()
                {
                    Schema      = dr["TABLE_SCHEMA"].ToString(),
                    Name        = dr["TABLE_NAME"].ToString(),
                    Description = string.Empty
                });
            }

            #endregion

            #region [1] Table Columns

            string defaultString;

            drs = ds.Tables[1].Rows;

            foreach (DataRow dr in drs)
            {
                table = this.database.Tables.GetItem(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString());

                specificDbType = dr["DATA_TYPE"].ToString();

                dbType = GetDbType(specificDbType);

                defaultString = dr["COLUMN_DEFAULT"].ToString();

                if (defaultString.StartsWith("(", StringComparison.OrdinalIgnoreCase) && defaultString.EndsWith(")", StringComparison.OrdinalIgnoreCase))
                {
                    defaultString = defaultString.Substring(1, defaultString.Length - 2);
                }

                table.Columns.Add(
                    new Column()
                {
                    Name           = dr["COLUMN_NAME"].ToString(),
                    DbType         = dbType,
                    SpecificDbType = specificDbType.ToLower(),
                    Size           = Convert.ToInt32(dr["CHARACTER_MAXIMUM_LENGTH"].ToString(), CultureInfo.InvariantCulture),
                    Default        = defaultString,
                    Nullable       = dr["IS_NULLABLE"].ToString() == "YES",
                    Description    = string.Empty,
                });
            }

            #endregion

            #region [2] Constraints

            drs = ds.Tables[2].Rows;

            foreach (DataRow dr in drs)
            {
                constraintName = dr["CONSTRAINT_NAME"].ToString();
                columnName     = dr["COLUMN_NAME"].ToString();

                if (this.database.Tables.Contains(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString()))
                {
                    table = this.database.Tables.GetItem(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString());

                    switch (dr["CONSTRAINT_TYPE"].ToString())
                    {
                    case "PRIMARY KEY":
                    {
                        table.PrimaryKey.Name = constraintName;
                        table.PrimaryKey.Columns.Add(table.Columns[columnName]);

                        break;
                    }

                    case "FOREIGN KEY":
                    {
                        if (table.ForeignKeys.Contains(constraintName))
                        {
                            table.ForeignKeys[constraintName].Columns.Add(table.Columns[columnName]);
                        }
                        else
                        {
                            foreignKey = new ForeignKey()
                            {
                                Name = constraintName
                            };
                            foreignKey.Columns.Add(table.Columns[columnName]);

                            if (this.database.Tables.Contains(dr["REFERENTIAL_TABLE_SCHEMA"].ToString(), dr["REFERENTIAL_TABLE_NAME"].ToString()))
                            {
                                foreignKey.ReferentialTableName = dr["REFERENTIAL_TABLE_SCHEMA"].ToString() + "." + dr["REFERENTIAL_TABLE_NAME"].ToString();
                            }

                            table.ForeignKeys.Add(foreignKey);
                        }

                        break;
                    }

                    case "UNIQUE KEY":
                    {
                        if (table.UniqueKeys.Contains(constraintName))
                        {
                            table.UniqueKeys[constraintName].Columns.Add(table.Columns[columnName]);
                        }
                        else
                        {
                            uniqueKey = new UniqueKey()
                            {
                                Name = constraintName
                            };
                            uniqueKey.Columns.Add(table.Columns[columnName]);

                            table.UniqueKeys.Add(uniqueKey);
                        }

                        break;
                    }
                    }
                }
            }

            #endregion

            #region [3] Table Indexes

            drs = ds.Tables[3].Rows;

            foreach (DataRow dr in drs)
            {
                table = this.database.Tables.GetItem(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString());

                key = dr["INDEX_NAME"].ToString();

                if (table.Indexes.Contains(key))
                {
                    table.Indexes[key].Columns.Add(table.Columns[dr["COLUMN_NAME"].ToString()]);
                }
                else
                {
                    table.Indexes.Add(
                        new Index()
                    {
                        Name = key
                    });
                }
            }

            #endregion

            #region [4] Views

            drs = ds.Tables[4].Rows;

            foreach (DataRow dr in drs)
            {
                this.database.Views.Add(
                    new View()
                {
                    Schema = dr["TABLE_SCHEMA"].ToString(),
                    Name   = dr["TABLE_NAME"].ToString()
                });
            }

            #endregion

            #region [5] View Columns

            drs = ds.Tables[5].Rows;

            foreach (DataRow dr in drs)
            {
                view = this.database.Views.GetItem(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString());

                specificDbType = dr["DATA_TYPE"].ToString();

                dbType = GetDbType(specificDbType);

                view.Columns.Add(
                    new Column()
                {
                    Name           = dr["COLUMN_NAME"].ToString(),
                    DbType         = dbType,
                    SpecificDbType = specificDbType,
                    Size           = Convert.ToInt32(dr["CHARACTER_MAXIMUM_LENGTH"].ToString(), CultureInfo.InvariantCulture),
                    Nullable       = dr["IS_NULLABLE"].ToString() == "YES",
                    Description    = string.Empty
                });
            }

            #endregion

            #region [6] View Indexes

            drs = ds.Tables[6].Rows;

            foreach (DataRow dr in drs)
            {
                view = this.database.Views.GetItem(dr["TABLE_SCHEMA"].ToString(), dr["TABLE_NAME"].ToString());

                key = dr["INDEX_NAME"].ToString();

                if (view.Indexes.Contains(key))
                {
                    view.Indexes[key].Columns.Add(view.Columns[dr["COLUMN_NAME"].ToString()]);
                }
                else
                {
                    view.Indexes.Add(
                        new Index()
                    {
                        Name = key
                    });
                }
            }

            #endregion

            #region [7] Procedures

            drs = ds.Tables[7].Rows;

            foreach (DataRow dr in drs)
            {
                this.database.Procedures.Add(
                    new Procedure()
                {
                    Schema      = dr["SPECIFIC_SCHEMA"].ToString(),
                    Name        = dr["SPECIFIC_NAME"].ToString(),
                    Definition  = dr["ROUTINE_DEFINITION"].ToString(),
                    Description = string.Empty
                });
            }

            #endregion

            #region [8] Procedure Parameters

            drs = ds.Tables[8].Rows;

            foreach (DataRow dr in drs)
            {
                if (this.database.Procedures.Contains(dr["SPECIFIC_SCHEMA"].ToString(), dr["SPECIFIC_NAME"].ToString()))
                {
                    procedure = this.database.Procedures.GetItem(dr["SPECIFIC_SCHEMA"].ToString(), dr["SPECIFIC_NAME"].ToString());

                    specificDbType = dr["DATA_TYPE"].ToString();
                    dbType         = GetDbType(specificDbType);

                    procedure.Parameters.Add(
                        new DbSharper2.Schema.Database.Parameter()
                    {
                        Name           = dr["PARAMETER_NAME"].ToString(),
                        DbType         = GetDbType(specificDbType),
                        SpecificDbType = specificDbType,
                        Size           = Convert.ToInt32(dr["CHARACTER_MAXIMUM_LENGTH"].ToString(), CultureInfo.InvariantCulture),
                        Direction      = GetParameterDirection(dr["PARAMETER_MODE"].ToString())
                    });
                }
            }

            #endregion

            #region [9] Descriptions

            string schema;
            string majorName;
            string minorName;
            string value;

            drs = ds.Tables[9].Rows;

            foreach (DataRow dr in drs)
            {
                schema    = dr["Schema"].ToString();
                majorName = dr["MajorName"].ToString();
                minorName = dr["MinorName"].ToString();
                value     = dr["Value"].ToString() ?? string.Empty;

                switch (dr["BaseType"].ToString().Trim())
                {
                case "U":
                {
                    if (string.IsNullOrEmpty(minorName))
                    {
                        this.database.Tables.GetItem(schema, majorName).Description = value;
                    }
                    else
                    {
                        this.database.Tables.GetItem(schema, majorName).Columns[minorName].Description = value;
                    }

                    break;
                }

                case "V":
                {
                    this.database.Views.GetItem(schema, majorName).Description = value;

                    break;
                }

                case "P":
                {
                    this.database.Procedures.GetItem(schema, majorName).Description = value;

                    break;
                }
                }
            }

            #endregion
        }
Ejemplo n.º 20
0
        public void FromRngWithLenghtSmallerThanCharsetThrowsException()
        {
            Action action = () => UniqueKey.FromRandomNumberGeneratedComplex(3);

            action.Should().Throw <ArgumentException>();
        }
Ejemplo n.º 21
0
 internal Tuple <GrainReference, GrainState <TestState1> > GetTestReferenceAndState(long grainId, string version)
 {
     return(Tuple.Create((GrainReference)this.grainFactory.GetGrain(LegacyGrainId.GetGrainId(UniqueKey.NewKey(grainId, UniqueKey.Category.Grain))), new GrainState <TestState1> {
         State = new TestState1(), ETag = version
     }));
 }
Ejemplo n.º 22
0
        /// <summary> Read an <c>GrainId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal static GrainId ReadGrainId(this IBinaryTokenStreamReader @this)
        {
            UniqueKey key = @this.ReadUniqueKey();

            return(GrainId.GetGrainId(key));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Constructor for creating a constraint from a Hibnerate UniqueKey object.
 /// </summary>
 /// <param name="table"></param>
 /// <param name="constraint"></param>
 internal ConstraintInfo(Table table, UniqueKey constraint)
     : this("UQ_", table.Name, constraint.ColumnIterator, constraint.Name)
 {
 }
Ejemplo n.º 24
0
 public void UniqueKeyKeyExtGrainCategoryDisallowsEmptyKeyExtension()
 {
     Assert.Throws <ArgumentException>(() =>
                                       UniqueKey.NewKey(Guid.NewGuid(), category: UniqueKey.Category.KeyExtGrain, keyExt: ""));
 }
Ejemplo n.º 25
0
        /// <summary> Read an <c>ActivationId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal ActivationId ReadActivationId()
        {
            UniqueKey key = ReadUniqueKey();

            return(ActivationId.GetActivationId(key));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Load the result of an Sql query into the metadatas object.
        /// </summary>
        /// <param name="reader">Result of an Sql query defined in <see cref="MetadataProvider.SqlGetUniqueKeys"/></param>
        /// <param name="metadata">Metadatas container</param>
        /// <param name="serverId">ServerId loaded from</param>
        /// <param name="database">Database loaded from</param>
        internal static void LoadUniqueKeys(IDataReader reader, Metadatas metadata, string serverId, string database)
        {
            var lstUniqueKeys       = new List <UniqueKey>();
            var lstUniqueKeyColumns = new List <string>();

            if (!reader.Read())
            {
                return;
            }

            //Init first row
            var currentSchema          = reader.GetString(0);
            var previousTable          = metadata[serverId][database][currentSchema].First(t => t.Name.Equals(reader.GetString(1), StringComparison.OrdinalIgnoreCase));
            var previousConstraintName = reader.GetString(2);
            var previousConstraint     = new UniqueKey();

            //Pour chaque ligne
            do
            {
                currentSchema = reader.GetString(0);
                var currentTable      = reader.GetString(1);
                var currentConstraint = reader.GetString(2);

                //Si on change de constraint
                if (currentTable != previousTable.Name || currentConstraint != previousConstraintName)
                {
                    previousConstraint.Columns = lstUniqueKeyColumns;
                    lstUniqueKeys.Add(previousConstraint);

                    lstUniqueKeyColumns    = new List <string>();
                    previousConstraint     = new UniqueKey();
                    previousConstraintName = currentConstraint;
                }

                //Si on change de table
                if (currentTable != previousTable.Name)
                {
                    previousTable.UniqueKeys = lstUniqueKeys;

                    //Change de table
                    previousTable = metadata[serverId][database][currentSchema].First(t => t.Name.Equals(reader.GetString(1), StringComparison.OrdinalIgnoreCase));
                    lstUniqueKeys = new List <UniqueKey>();
                }

                //Ajoute la colonne
                var colName = reader.GetString(3);
                lstUniqueKeyColumns.Add(colName);

                //Affecte l'indicateur dans le schema
                var col = previousTable.ColumnsDefinition.FirstOrDefault(c => c.Name.Equals(colName, StringComparison.OrdinalIgnoreCase));
                if (col == null)
                {
                    throw new Exception($"The column {colName} has not been found in the metadata for the table {previousTable.Name}.");
                }
                col.IsUniqueKey = true;
            } while (reader.Read());

            //Ajoute la dernière table / schema
            if (lstUniqueKeyColumns.Count > 0)
            {
                previousConstraint.Columns = lstUniqueKeyColumns;
                lstUniqueKeys.Add(previousConstraint);
                previousTable.UniqueKeys = lstUniqueKeys;
            }
        }
Ejemplo n.º 27
0
 public Node Get(UniqueKey key)
 {
     return(null);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Apply the merge using the UniqueKey to match items between JSON and entity.
        /// </summary>
        private static JsonEntityMergeResult MergeApplyUniqueKeyItems(JsonEntityMergeArgs args, IPropertyReflector pr, JProperty jp, object entity)
        {
            var hasError   = false;
            var hasChanges = false;
            var count      = 0;
            var ukc        = (UniqueKeyConfig)pr.Tag;
            var lo         = new List <object>();
            var ier        = pr.GetItemEntityReflector();

            // Determine the unique key for a comparison.
            var ukpr = ukc.GetPropertyReflectors(ier);

            // Get the current value to update.
            var current = (IEnumerable)pr.PropertyExpression.GetValue(entity);

            if (current == null)
            {
                hasChanges = true;
            }

            // Merge each item into the new collection.
            foreach (var ji in jp.Values())
            {
                // Check not null.
                if (ji.Type != JTokenType.Object)
                {
                    hasError = true;
                    args.Log(MessageItem.CreateErrorMessage(ji.Path, "The JSON token must be an object where Unique Key value(s) are required."));
                    continue;
                }

                // Generate the unique key from the json properties.
                bool skip = false;
                var  uk   = new object[ukpr.Length];
                for (int i = 0; i < ukc.Properties.Length; i++)
                {
                    var jk = ji[ukpr[i].JsonName];
                    if (jk == null)
                    {
                        hasError = skip = true;
                        args.Log(MessageItem.CreateErrorMessage(ji.Path, $"The JSON object must specify the '{ukpr[i].JsonName}' token as required for the unique key."));
                        break;
                    }

                    try
                    {
                        uk[i] = ukpr[i].GetJtokenValue(jk);
                    }
                    catch (FormatException fex)
                    {
                        hasError = skip = true;
                        args.Log(MessageItem.CreateMessage(jk.Path, MessageType.Error, $"The JSON token is malformed: {fex.Message}"));
                        break;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }

                if (skip)
                {
                    continue;
                }

                // Get existing by unique key.
                var uniqueKey = new UniqueKey(uk);
                var item      = current == null ? null : ukc.IsEntityBaseCollection
                    ? ((IEntityBaseCollection)current).GetByUniqueKey(uniqueKey)
                    : current.OfType <EntityBase>().FirstOrDefault(x => uniqueKey.Equals(x.UniqueKey));

                // Create new if not found.
                if (item == null)
                {
                    hasChanges = true;
                    item       = pr.ComplexTypeReflector.CreateItemValue();
                }

                // Update.
                count++;
                var mr = MergeApply(args, ier, ji, item);
                if (mr == JsonEntityMergeResult.Error)
                {
                    hasError = true;
                }
                else
                {
                    if (mr == JsonEntityMergeResult.SuccessWithChanges)
                    {
                        hasChanges = true;
                    }

                    lo.Add(item);
                }
            }

            if (hasError)
            {
                return(JsonEntityMergeResult.Error);
            }

            // Confirm nothing was deleted (only needed where nothing changed so far).
            if (!hasChanges && count == (ukc.IsEntityBaseCollection ? ((IEntityBaseCollection)current).Count : current.OfType <EntityBase>().Count()))
            {
                return(JsonEntityMergeResult.SuccessNoChanges);
            }

            pr.ComplexTypeReflector.SetValue(entity, lo);
            return(JsonEntityMergeResult.SuccessWithChanges);
        }
Ejemplo n.º 29
0
 public IEnumerable <Node> GetAll(UniqueKey key)
 {
     return(Enumerable.Empty <Node>());
 }
Ejemplo n.º 30
0
 public void UniqueKeyKeyExtGrainCategoryDisallowsWhiteSpaceKeyExtension()
 {
     UniqueKey.NewKey(Guid.NewGuid(), category: UniqueKey.Category.KeyExtGrain, keyExt: " \t\n\r");
 }
Ejemplo n.º 31
0
 public void Update(UniqueKey key, Node item)
 {
 }
Ejemplo n.º 32
0
        /// <summary> Read an <c>GrainId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal static GrainId ReadGrainId <TReader>(this TReader @this) where TReader : IBinaryTokenStreamReader
        {
            UniqueKey key = @this.ReadUniqueKey();

            return(GrainId.GetGrainId(key));
        }
Ejemplo n.º 33
0
        /// <summary> Read an <c>ActivationId</c> value from the stream. </summary>
        /// <returns>Data from current position in stream, converted to the appropriate output type.</returns>
        internal static ActivationId ReadActivationId <TReader>(this TReader @this) where TReader : IBinaryTokenStreamReader
        {
            UniqueKey key = @this.ReadUniqueKey();

            return(ActivationId.GetActivationId(key));
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Gets a unique key by its name, or creates it if not found.
 /// </summary>
 public UniqueKey GetOrCreateUniqueKey(String keyName)
 {
     UniqueKey uk = null;
     if (_uniqueKeys.ContainsKey(keyName))
         uk = _uniqueKeys[keyName];
     else
     {
         uk = new UniqueKey();
         uk.Name = keyName;
         uk.Table = this;
         _uniqueKeys.Add(keyName, uk);
     }
     return uk;
 }
Ejemplo n.º 35
0
        public void FromRngCustomLenght()
        {
            const int Lenght = 10;

            CheckRandomGenerated(UniqueKey.FromRng(Lenght), Lenght);
        }
Ejemplo n.º 36
0
		protected override IEnumerable<DbParameter> CoreGetUniqueKeyColumnParameters(Type connectionType, string dataSourceTag, Server server, Database database, Schema schema, Table table, UniqueKey uniqueKey)
		{
			if ((object)connectionType == null)
				throw new ArgumentNullException(nameof(connectionType));

			if ((object)dataSourceTag == null)
				throw new ArgumentNullException(nameof(dataSourceTag));

			if ((object)server == null)
				throw new ArgumentNullException(nameof(server));

			if ((object)database == null)
				throw new ArgumentNullException(nameof(database));

			if ((object)schema == null)
				throw new ArgumentNullException(nameof(schema));

			if ((object)table == null)
				throw new ArgumentNullException(nameof(table));

			if ((object)uniqueKey == null)
				throw new ArgumentNullException(nameof(uniqueKey));

			if (dataSourceTag.SafeToString().ToLower() == ODBC_SQL_SERVER_DATA_SOURCE_TAG)
			{
				return new DbParameter[]
						{
							//DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P1", server.ServerName),
							//DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P2", database.DatabaseName),
							DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.CreateParameter(connectionType, null, ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P3", schema.SchemaName),
							//DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.CreateParameter(connectionType, null,ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P4", table.TableName),
							DatazoidLegacyInstanceAccessor.AdoNetBufferingLegacyInstance.CreateParameter(connectionType, null, ParameterDirection.Input, DbType.String, 100, 0, 0, true, "@P5", uniqueKey.UniqueKeyName)
						};
			}

			throw new ArgumentOutOfRangeException(string.Format("dataSourceTag: '{0}'", dataSourceTag));
		}
Ejemplo n.º 37
0
        public async Task GremlinGraphCreateUpdateTests()
        {
            IList <IncludedPath> includedPath = new List <IncludedPath> {
                new IncludedPath {
                    Path = "/*"
                }
            };
            IList <ExcludedPath> excludedPaths = new List <ExcludedPath> {
                new ExcludedPath {
                    Path = "/pathToNotIndex/*"
                }
            };
            IList <IList <CompositePath> > compositeIndexes = new List <IList <CompositePath> >
            {
                new List <CompositePath>
                {
                    new CompositePath {
                        Path = "/orderByPath1", Order = CompositePathSortOrder.Ascending
                    },
                    new CompositePath {
                        Path = "/orderByPath2", Order = CompositePathSortOrder.Descending
                    }
                },
                new List <CompositePath>
                {
                    new CompositePath {
                        Path = "/orderByPath3", Order = CompositePathSortOrder.Ascending
                    },
                    new CompositePath {
                        Path = "/orderByPath4", Order = CompositePathSortOrder.Descending
                    }
                }
            };
            IList <SpatialSpec> spatialIndexes = new List <SpatialSpec> {
                new SpatialSpec("/*", new List <SpatialType> {
                    new SpatialType("Point")
                })
            };

            IndexingPolicyResource indexingPolicy = new IndexingPolicy(true, IndexingMode.Consistent, includedPath, excludedPaths, compositeIndexes, spatialIndexes);

            ContainerPartitionKey containerPartitionKey = new ContainerPartitionKey(new List <string> {
                "/address"
            }, "Hash", null);
            IList <string> paths = new List <string>()
            {
                "/testpath"
            };
            UniqueKey         uk         = new UniqueKey(paths);
            IList <UniqueKey> uniqueKeys = new List <UniqueKey>();

            uniqueKeys.Add(uk);
            UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(uniqueKeys);

            ConflictResolutionPolicy conflictResolutionPolicy = new ConflictResolutionPolicy(new ConflictResolutionMode("LastWriterWins"), "/path", "");
            CreateUpdateOptions      createUpdateOptions      = new CreateUpdateOptions(sampleThroughput, new AutoscaleSettings());

            GremlinGraphCreateUpdateParameters gremlinGraphCreateUpdateParameters = new GremlinGraphCreateUpdateParameters(new GremlinGraphResource(gremlinGraphName, indexingPolicy, containerPartitionKey, -1, uniqueKeyPolicy, conflictResolutionPolicy), createUpdateOptions);

            Response <GremlinGraphResource> gremlinResponse = await WaitForCompletionAsync(await CosmosDBManagementClient.GremlinResources.StartCreateUpdateGremlinGraphAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName, gremlinGraphCreateUpdateParameters));

            Assert.NotNull(gremlinResponse);
            GremlinGraphResource gremlinGraph = gremlinResponse.Value;

            Assert.NotNull(gremlinGraph);

            VerifyGremlinGraphCreation(gremlinGraph, gremlinGraphCreateUpdateParameters);

            var throughputResponse = CosmosDBManagementClient.GremlinResources.GetGremlinGraphThroughputAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName);
            ThroughputSettingsData ThroughputSettingsData = throughputResponse.ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.NotNull(throughputSettings);
            Assert.NotNull(throughputSettings.Name);
            Assert.AreEqual(throughputSettings.Resource.Throughput, sampleThroughput);
            Assert.AreEqual(gremlinGraphsThroughputType, throughputSettings.Type);

            CreateUpdateOptions createUpdateOptions2 = new CreateUpdateOptions(sampleThroughput2, new AutoscaleSettings());
            GremlinGraphCreateUpdateParameters gremlinGraphCreateUpdateParameters2 = new GremlinGraphCreateUpdateParameters(new GremlinGraphResource(gremlinGraphName, indexingPolicy, containerPartitionKey, -1, uniqueKeyPolicy, conflictResolutionPolicy), createUpdateOptions2);

            Response <GremlinGraphResource> gremlinResponse2 = await WaitForCompletionAsync(await CosmosDBManagementClient.GremlinResources.StartCreateUpdateGremlinGraphAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName, gremlinGraphCreateUpdateParameters2));

            Assert.NotNull(gremlinResponse2);
            GremlinGraphResource gremlinGraph2 = gremlinResponse2.Value;

            Assert.NotNull(gremlinGraph2);

            VerifyGremlinGraphCreation(gremlinGraph2, gremlinGraphCreateUpdateParameters2);

            var throughputResponse2 = CosmosDBManagementClient.GremlinResources.GetGremlinGraphThroughputAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName);
            ThroughputSettingsData throughputSettings2 = throughputResponse2.ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.NotNull(throughputSettings2);
            Assert.NotNull(throughputSettings2.Name);
            Assert.AreEqual(throughputSettings2.Resource.Throughput, sampleThroughput2);
            Assert.AreEqual(gremlinGraphsThroughputType, throughputSettings2.Type);
        }