public void Test_DqlConnection_States() { string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos"; using (DqlConnection cn = new DqlConnection(cnstr)) { Assert.IsTrue(cn.State == ConnectionState.Closed, "State is Closed"); cn.Open(); Assert.IsTrue(cn.State == ConnectionState.Open, "State is Open"); } }
/// <summary> /// Gets the schema model. /// </summary> /// <param name="tableName">Name of the table.</param> /// <returns>TableSchemaModel.</returns> public override TableSchemaModel GetSchemaModel(string tableName) { TableSchemaModel table = new TableSchemaModel(); using (DqlConnection cn = new DqlConnection(ConnectionString)) { cn.Open(); var schema = cn.GetSchema(tableName).AsEnumerable().GroupBy(g => g.Field <string>("name")); foreach (var item in schema) { FillSchemaModel(table, item); } } return(table); }
public void Test_DqlFill_Schema() { string select = "Select * from dm_cabinet enable(return_top 1)"; string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos"; DataSet dataset = new DataSet(); using (var cn = new DqlConnection(cnstr)) { cn.Open(); using (var cmd = new DqlCommand(select, cn)) { using (var adapter = new DqlDataAdapter(cmd)) { adapter.FillSchema(dataset); } } } }
/// <summary> /// Executes the query. /// </summary> /// <param name="select">The select.</param> /// <returns>DataSet.</returns> public override DataSet ExecuteQuery(string select) { DataSet dataSet = null; using (var cn = new DqlConnection(ConnectionString)) { cn.Open(); using (DqlCommand cmd = new DqlCommand(select, cn)) { using (DqlDataAdapter adapter = new DqlDataAdapter(cmd)) { dataSet = new DataSet(); adapter.Fill(dataSet); } } } return(dataSet); }
/// <summary> /// Texts the documentum. /// </summary> private void TestDocumentum() { DqlConnectionStringBuilder builder = new DqlConnectionStringBuilder(txtUserId.Text, txtPassword.Text, btnDataSource.Text); builder["Extended Properties"] = txtExt.Text; DqlDataSource ds = new DqlDataSource(builder.ConnectionString); if (ds.UseExternalQueryEngine()) { ds.TestConnection(); return; } using (DqlConnection cn = new DqlConnection(builder.ConnectionString)) { cn.Open(); } }
public void Test_DqlFill_RepeatingValues() { string select = "select r_object_id, object_name, keywords, authors from dm_cabinet where not object_name like 'dm%' and object_name = 'ls_repos'"; DataSet dataset = new DataSet(); string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos"; using (DqlConnection cn = new DqlConnection(cnstr)) { cn.Open(); using (DqlCommand cmd = new DqlCommand(select, cn)) { using (DqlDataAdapter adapter = new DqlDataAdapter(cmd)) { var schemas = adapter.FillSchema(dataset, SchemaType.Source); Assert.AreEqual(dataset.Tables[0].Rows[0]["keywords"].ToString(), "test2|test3|test1"); Assert.AreEqual(dataset.Tables[0].Rows[0]["authors"].ToString(), "author2|author3|author1"); } } } }
public void Test_DqlFill() { string select = "Select r_object_id, keywords from dm_cabinet enable(return_top 1); select * from dm_document enable(return_top 1)"; DataSet dataset = new DataSet(); string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos"; using (DqlConnection cn = new DqlConnection(cnstr)) { cn.Open(); using (DqlCommand cmd = new DqlCommand(select, cn)) { using (DqlDataAdapter adapter = new DqlDataAdapter(cmd)) { var schemas = adapter.Fill(dataset); Assert.AreEqual(dataset.Tables.Count, 2); Assert.AreEqual(dataset.Tables[0].Rows.Count, 1); Assert.AreEqual(dataset.Tables[1].Rows.Count, 1); } } } }
public void Test_DqlMultiQuery() { DataSet dataset = new DataSet("MulitQueryTest"); string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos"; using (DqlConnection cn = new DqlConnection(cnstr)) { cn.Open(); using (DqlCommand cmd = new DqlCommand(File.ReadAllText(".\\DqlMultiQueryTest.txt"), cn)) { using (DqlDataAdapter adapter = new DqlDataAdapter(cmd)) { var schemas = adapter.Fill(dataset); var table = dataset.MergeAll(); Assert.AreEqual(dataset.Tables.Count, 21); Assert.AreEqual(table.Rows.Count, 10000); //Assert.AreEqual(dataset.Tables[0].Rows.Count, 1); //Assert.AreEqual(dataset.Tables[1].Rows.Count, 1); } } } }
/// <summary> /// Executes the query. /// </summary> /// <param name="select">The select.</param> /// <param name="token">The token.</param> /// <returns>DataSet.</returns> public override DataSet ExecuteQuery(string select, CancellationToken token) { if (UseExternalQueryEngine()) { return(ExecuteQueryExternal(select)); } DataSet dataSet = null; using (var cn = new DqlConnection(ConnectionString)) { cn.Open(); using (DqlCommand cmd = new DqlCommand(select, cn)) { using (DqlDataAdapter adapter = new DqlDataAdapter(cmd)) { dataSet = new DataSet(); adapter.Fill(dataSet, token); } } } return(dataSet); }
/// <summary> /// Gets the schema model. /// </summary> /// <returns>List<TableSchemaModel>.</returns> public override List <TableSchemaModel> GetSchemaModel() { if (UseExternalQueryEngine()) { return(GetSchemaModelExternal()); } DqlDataTypeMap map = new DqlDataTypeMap(); List <TableSchemaModel> tableSchemaModel = new List <TableSchemaModel>(); using (DqlConnection cn = new DqlConnection(ConnectionString)) { cn.Open(); var schema = cn.GetSchema().AsEnumerable().GroupBy(g => g.Field <string>("name")); foreach (var item in schema) { TableSchemaModel table = new TableSchemaModel(); tableSchemaModel.Add(table); FillSchemaModel(table, item); } } return(tableSchemaModel); }