From a4ef38afbc4b451d984ede6964b3d2e3cdd28667 Mon Sep 17 00:00:00 2001 From: Marco De Salvo Date: Thu, 5 Dec 2024 11:19:36 +0100 Subject: [PATCH] Slight code cleanups --- .../Query/Mirella/RDFQueryEngineTest.cs | 3 +-- RDFSharp/Model/RDFGraph.cs | 6 +++--- RDFSharp/Query/Mirella/RDFOperationEngine.cs | 16 ++++++++-------- RDFSharp/Query/Mirella/RDFQueryEngine.cs | 7 +------ RDFSharp/Store/RDFStore.cs | 8 ++++---- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/RDFSharp.Test/Query/Mirella/RDFQueryEngineTest.cs b/RDFSharp.Test/Query/Mirella/RDFQueryEngineTest.cs index 2e619fd5..c87594c9 100644 --- a/RDFSharp.Test/Query/Mirella/RDFQueryEngineTest.cs +++ b/RDFSharp.Test/Query/Mirella/RDFQueryEngineTest.cs @@ -52,7 +52,6 @@ public void ShouldCreateQueryEngine() Assert.IsNotNull(queryEngine); Assert.IsNotNull(queryEngine.PatternGroupMemberResultTables); Assert.IsNotNull(queryEngine.QueryMemberResultTables); - Assert.IsTrue(RDFQueryEngine.SystemString.Equals(typeof(string))); } [TestMethod] @@ -5405,7 +5404,7 @@ public void ShouldAddDataColumn() Assert.IsTrue(table.Columns.Count == 1); Assert.IsTrue(string.Equals(table.Columns[0].ColumnName, "?COL")); - Assert.IsTrue(table.Columns[0].DataType.Equals(RDFQueryEngine.SystemString)); + Assert.IsTrue(table.Columns[0].DataType.Equals(typeof(string))); } [TestMethod] diff --git a/RDFSharp/Model/RDFGraph.cs b/RDFSharp/Model/RDFGraph.cs index e9172a3e..32d662e7 100644 --- a/RDFSharp/Model/RDFGraph.cs +++ b/RDFSharp/Model/RDFGraph.cs @@ -607,9 +607,9 @@ public DataTable ToDataTable() { //Create the structure of the result datatable DataTable result = new DataTable(ToString()); - result.Columns.Add("?SUBJECT", RDFQueryEngine.SystemString); - result.Columns.Add("?PREDICATE", RDFQueryEngine.SystemString); - result.Columns.Add("?OBJECT", RDFQueryEngine.SystemString); + result.Columns.Add("?SUBJECT", typeof(string)); + result.Columns.Add("?PREDICATE", typeof(string)); + result.Columns.Add("?OBJECT", typeof(string)); //Iterate the triples of the graph to populate the result datatable result.BeginLoadData(); diff --git a/RDFSharp/Query/Mirella/RDFOperationEngine.cs b/RDFSharp/Query/Mirella/RDFOperationEngine.cs index 7129e3c5..555971bc 100644 --- a/RDFSharp/Query/Mirella/RDFOperationEngine.cs +++ b/RDFSharp/Query/Mirella/RDFOperationEngine.cs @@ -408,10 +408,10 @@ private DataTable PopulateInsertOperationResults(List insertDataTemp { DataTable resultTable = new DataTable("INSERT_RESULTS"); if (datasource.IsStore()) - resultTable.Columns.Add("?CONTEXT", SystemString); - resultTable.Columns.Add("?SUBJECT", SystemString); - resultTable.Columns.Add("?PREDICATE", SystemString); - resultTable.Columns.Add("?OBJECT", SystemString); + resultTable.Columns.Add("?CONTEXT", typeof(string)); + resultTable.Columns.Add("?SUBJECT", typeof(string)); + resultTable.Columns.Add("?PREDICATE", typeof(string)); + resultTable.Columns.Add("?OBJECT", typeof(string)); Dictionary bindings = new Dictionary(); insertDataTemplates.ForEach(insertTemplate => @@ -469,10 +469,10 @@ private DataTable PopulateDeleteOperationResults(List deleteDataTemp { DataTable resultTable = new DataTable("DELETE_RESULTS"); if (datasource.IsStore()) - resultTable.Columns.Add("?CONTEXT", SystemString); - resultTable.Columns.Add("?SUBJECT", SystemString); - resultTable.Columns.Add("?PREDICATE", SystemString); - resultTable.Columns.Add("?OBJECT", SystemString); + resultTable.Columns.Add("?CONTEXT", typeof(string)); + resultTable.Columns.Add("?SUBJECT", typeof(string)); + resultTable.Columns.Add("?PREDICATE", typeof(string)); + resultTable.Columns.Add("?OBJECT", typeof(string)); Dictionary bindings = new Dictionary(); deleteDataTemplates.ForEach(deleteTemplate => diff --git a/RDFSharp/Query/Mirella/RDFQueryEngine.cs b/RDFSharp/Query/Mirella/RDFQueryEngine.cs index 5779d9a3..92461352 100644 --- a/RDFSharp/Query/Mirella/RDFQueryEngine.cs +++ b/RDFSharp/Query/Mirella/RDFQueryEngine.cs @@ -45,11 +45,6 @@ internal class RDFQueryEngine /// internal Dictionary QueryMemberResultTables { get; set; } - /// - /// Default column type used for Mirella tables - /// - internal static readonly Type SystemString = typeof(string); - /// /// Attribute denoting an optional pattern/patternGroup/query /// @@ -1405,7 +1400,7 @@ internal static void AddColumn(DataTable table, string columnName) { string colName = columnName.Trim().ToUpperInvariant(); if (!table.Columns.Contains(colName)) - table.Columns.Add(colName, SystemString); + table.Columns.Add(colName, typeof(string)); } /// diff --git a/RDFSharp/Store/RDFStore.cs b/RDFSharp/Store/RDFStore.cs index f115b4c8..ff4e84fb 100644 --- a/RDFSharp/Store/RDFStore.cs +++ b/RDFSharp/Store/RDFStore.cs @@ -380,10 +380,10 @@ public DataTable ToDataTable() { //Create the structure of the result datatable DataTable result = new DataTable(ToString()); - result.Columns.Add("?CONTEXT", RDFQueryEngine.SystemString); - result.Columns.Add("?SUBJECT", RDFQueryEngine.SystemString); - result.Columns.Add("?PREDICATE", RDFQueryEngine.SystemString); - result.Columns.Add("?OBJECT", RDFQueryEngine.SystemString); + result.Columns.Add("?CONTEXT", typeof(string)); + result.Columns.Add("?SUBJECT", typeof(string)); + result.Columns.Add("?PREDICATE", typeof(string)); + result.Columns.Add("?OBJECT", typeof(string)); //Iterate the quadruples of the store to populate the result datatable result.BeginLoadData();