You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2019/04/07 07:49:21 UTC
[ignite] branch master updated: IGNITE-11525 .NET: Deprecate
SqlQuery API (#6415)
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 9fb5e46 IGNITE-11525 .NET: Deprecate SqlQuery API (#6415)
9fb5e46 is described below
commit 9fb5e46b2353e15e290d834b70f458fcc4ce7778
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Sun Apr 7 10:49:10 2019 +0300
IGNITE-11525 .NET: Deprecate SqlQuery API (#6415)
* Mark APIs as Obsolete
* Remove from examples
---
.../Binary/Serializable/SqlDmlTest.cs | 2 +
.../Query/CacheQueriesCodeConfigurationTest.cs | 4 ++
.../Cache/Query/CacheQueriesTest.cs | 24 ++++++--
.../Client/Cache/CacheClientAsyncWrapper.cs | 4 +-
.../Client/Cache/CacheTestNoMeta.cs | 2 +
.../Client/Cache/SqlQueryTest.cs | 4 ++
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 2 +
.../Client/Cache/ICacheClient.cs | 2 +
.../Impl/Client/Cache/CacheClient.cs | 2 +
.../NuGet/LINQPad/BinaryModeExample.linq | 5 --
.../NuGet/LINQPad/QueryExample.linq | 7 +--
.../Datagrid/BinaryModeExample.cs | 39 ++++---------
.../Apache.Ignite.Examples/Sql/SqlExample.cs | 38 ++++---------
.../ThinClient/ThinClientSqlExample.cs | 37 +++----------
.../dotnet/examples/dotnetcore/LinqExample.cs | 4 +-
.../dotnet/examples/dotnetcore/SqlExample.cs | 64 +++++++++++-----------
16 files changed, 104 insertions(+), 136 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs
index 005488a..4d523ba 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/Serializable/SqlDmlTest.cs
@@ -99,7 +99,9 @@ namespace Apache.Ignite.Core.Tests.Binary.Serializable
};
// Test SQL.
+#pragma warning disable 618
var res = cache.Query(new SqlQuery(typeof(SimpleSerializable), "where Int = 2")).GetAll().Single();
+#pragma warning restore 618
Assert.AreEqual(2, res.Key);
Assert.AreEqual(2, res.Value.Int);
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
index 1d03c68..1e760e6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -85,7 +85,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
cache[1] = new QueryPerson("Arnold", 10);
cache[2] = new QueryPerson("John", 20);
+#pragma warning disable 618
using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > ? and birthday < ?",
+#pragma warning restore 618
10, DateTime.UtcNow)))
{
Assert.AreEqual(2, cursor.GetAll().Single().Key);
@@ -176,6 +178,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
cache[2] = new AttributeQueryPerson("John", 20);
+#pragma warning disable 618
using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson),
"age > ? and age < ? and birthday > ? and birthday < ?", 10, 30,
DateTime.UtcNow.AddYears(-21), DateTime.UtcNow.AddYears(-19))))
@@ -197,6 +200,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
{
Assert.AreEqual(1, cursor.GetAll().Single().Key);
}
+#pragma warning restore 618
using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Ar*")))
{
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index bee6ffd..be35850 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -139,6 +139,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
[Test]
public void TestValidationSql()
{
+#pragma warning disable 618
// 1. No sql.
Assert.Throws<ArgumentException>(() =>
{ Cache().Query(new SqlQuery(typeof(QueryPerson), null)); });
@@ -146,6 +147,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
// 2. No type.
Assert.Throws<ArgumentException>(() =>
{ Cache().Query(new SqlQuery((string)null, "age >= 50")); });
+#pragma warning restore 618
}
/// <summary>
@@ -184,7 +186,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
Cache().Put(1, new QueryPerson("Petrov", 40));
Cache().Put(1, new QueryPerson("Sidorov", 50));
+#pragma warning disable 618
SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age >= 20");
+#pragma warning restore 618
// 1. Test GetAll().
using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
@@ -212,6 +216,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
[SuppressMessage("ReSharper", "UnusedVariable")]
public void TestEnumerator()
{
+#pragma warning disable 618
Cache().Put(1, new QueryPerson("Ivanov", 30));
Cache().Put(2, new QueryPerson("Petrov", 40));
Cache().Put(3, new QueryPerson("Sidorov", 50));
@@ -219,7 +224,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
// 1. Empty result set.
using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
- Cache().Query(new SqlQuery(typeof(QueryPerson), "age = 100")))
+ Cache().Query(new SqlQuery(typeof(QueryPerson), "age = 100")))
{
IEnumerator<ICacheEntry<int, QueryPerson>> e = cursor.GetEnumerator();
@@ -251,6 +256,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
// 4. Page size if less than result set.
qry.PageSize = 2;
CheckEnumeratorQuery(qry);
+#pragma warning restore 618
}
/// <summary>
@@ -259,18 +265,18 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
[Test]
public void TestSqlQueryArguments()
{
+#pragma warning disable 618
Cache().Put(1, new QueryPerson("Ivanov", 30));
Cache().Put(2, new QueryPerson("Petrov", 40));
Cache().Put(3, new QueryPerson("Sidorov", 50));
// 1. Empty result set.
- using (
- IQueryCursor<ICacheEntry<int, QueryPerson>> cursor =
- Cache().Query(new SqlQuery(typeof(QueryPerson), "age < ?", 50)))
+ using (var cursor = Cache().Query(new SqlQuery(typeof(QueryPerson), "age < ?", 50)))
{
foreach (ICacheEntry<int, QueryPerson> entry in cursor.GetAll())
Assert.IsTrue(entry.Key == 1 || entry.Key == 2);
}
+#pragma warning restore 618
}
/// <summary>
@@ -295,6 +301,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check query result for enumerator test.
/// </summary>
/// <param name="qry">QUery.</param>
+#pragma warning disable 618
private void CheckEnumeratorQuery(SqlQuery qry)
{
using (IQueryCursor<ICacheEntry<int, QueryPerson>> cursor = Cache().Query(qry))
@@ -333,6 +340,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
Assert.IsTrue(first && second && third);
}
}
+#pragma warning restore 618
/// <summary>
/// Check SQL query.
@@ -347,14 +355,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var exp = PopulateCache(cache, loc, MaxItemCnt, x => x < 50);
// 2. Validate results.
+#pragma warning disable 618
var qry = new SqlQuery(typeof(QueryPerson), "age < 50", loc)
{
EnableDistributedJoins = distrJoin,
-#pragma warning disable 618
ReplicatedOnly = false,
-#pragma warning restore 618
Timeout = TimeSpan.FromSeconds(3)
};
+#pragma warning restore 618
Assert.AreEqual(string.Format("SqlQuery [Sql=age < 50, Arguments=[], Local={0}, " +
"PageSize=1024, EnableDistributedJoins={1}, Timeout={2}, " +
@@ -524,7 +532,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
"Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.", err.Message);
// SQL query.
+#pragma warning disable 618
err = Assert.Throws<IgniteException>(() => cache.Query(new SqlQuery(typeof(QueryPerson), "age < 50")));
+#pragma warning restore 618
Assert.AreEqual("Failed to find SQL table for type: QueryPerson", err.Message);
}
@@ -767,10 +777,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var cache = Cache();
PopulateCache(cache, false, 30000, x => true);
+#pragma warning disable 618
var sqlQry = new SqlQuery(typeof(QueryPerson), "WHERE age < 2000")
{
Timeout = TimeSpan.FromMilliseconds(1)
};
+#pragma warning restore 618
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
var ex = Assert.Throws<CacheException>(() => cache.Query(sqlQry).ToArray());
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
index 6d812cf..8ad4478 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
@@ -134,10 +134,12 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
}
/** <inheritDoc /> */
+#pragma warning disable 618
public IQueryCursor<ICacheEntry<TK, TV>> Query(SqlQuery sqlQuery)
{
return _cache.Query(sqlQuery);
}
+#pragma warning restore 618
/** <inheritDoc /> */
public IFieldsQueryCursor Query(SqlFieldsQuery sqlFieldsQuery)
@@ -349,4 +351,4 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
return _cache.WithKeepBinary<TK1, TV1>();
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
index 1978243..0c72010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
@@ -71,10 +71,12 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
Assert.AreEqual(200, serverCache[2].Id);
// SQL from server cache.
+#pragma warning disable 618
var sqlRes = serverCache.Query(new SqlQuery(typeof(Person), "where id = 100")).GetAll().Single();
Assert.AreEqual(1, sqlRes.Key);
Assert.AreEqual(100, sqlRes.Value.Id);
Assert.AreEqual("foo", sqlRes.Value.Name);
+#pragma warning restore 618
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs
index 760a48d..9584af8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/SqlQueryTest.cs
@@ -34,6 +34,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
[Test]
public void TestSqlQuery()
{
+#pragma warning disable 618
var cache = GetClientCache<Person>();
// All items.
@@ -63,6 +64,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
qry.Sql = "abc";
qry.QueryType = null;
Assert.Throws<ArgumentNullException>(() => cache.Query(qry));
+#pragma warning restore 618
}
/// <summary>
@@ -71,6 +73,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
[Test]
public void TestSqlQueryDistributedJoins()
{
+#pragma warning disable 618
var cache = GetClientCache<Person>();
// Non-distributed join returns incomplete results.
@@ -83,6 +86,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
// Distributed join fixes the problem.
qry.EnableDistributedJoins = true;
Assert.AreEqual(Count, cache.Query(qry).Count());
+#pragma warning restore 618
}
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
index 4c979ed..d0e77ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
@@ -27,6 +27,8 @@ namespace Apache.Ignite.Core.Cache.Query
/// <summary>
/// SQL Query.
/// </summary>
+ [Obsolete("Use SqlFieldsQuery instead. For strongly-typed queries use Apache.Ignite.Linq. " +
+ "SqlQuery is a limited subset of SqlFieldsQuery.")]
public class SqlQuery : QueryBase
{
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
index 818a7f6..ab98e15 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
@@ -154,6 +154,8 @@ namespace Apache.Ignite.Core.Client.Cache
/// </summary>
/// <param name="sqlQuery">SQL query.</param>
/// <returns>Query cursor.</returns>
+ [Obsolete("Use SqlFieldsQuery instead. For strongly-typed queries use Apache.Ignite.Linq. " +
+ "SqlQuery is a limited subset of SqlFieldsQuery.")]
IQueryCursor<ICacheEntry<TK, TV>> Query(SqlQuery sqlQuery);
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
index d930b51..99b4f34 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
@@ -206,6 +206,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
}
/** <inheritDoc /> */
+ [Obsolete]
public IQueryCursor<ICacheEntry<TK, TV>> Query(SqlQuery sqlQuery)
{
IgniteArgumentCheck.NotNull(sqlQuery, "sqlQuery");
@@ -671,6 +672,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
/// <summary>
/// Writes the SQL query.
/// </summary>
+ [Obsolete]
private static void WriteSqlQuery(IBinaryRawWriter writer, SqlQuery qry)
{
Debug.Assert(qry != null);
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq
index f72c2e1..0fe0d20 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq
@@ -83,11 +83,6 @@ using (var ignite = Ignition.Start())
cache[1] = person.ToBuilder().SetField("Name", name + " Jr.").Build();
cache[1].ToString().Dump("Modified person with id 1:");
- // Run SQL query.
- cache.Query(new SqlQuery("Person", "age < 40"))
- .Select(x => x.Value.ToString())
- .Dump("Persons with age less than 40:");
-
// Run SQL fields query.
cache.Query(new SqlFieldsQuery("select name from Person order by name"))
.Dump("All person names:");
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq
index ae48596..76bfaa0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq
@@ -57,16 +57,13 @@ void Main()
persons[5] = new Person { OrgId = 3, Name = "Christopher Adams" };
// SQL query
- orgs.Query(new SqlQuery(typeof(Organization), "size < ?", 100000)).Dump("Organizations with size less than 100K");
+ orgs.Query(new SqlFieldsQuery("select * from Organization where size < ?", 100000)).Dump("Organizations with size less than 100K");
// SQL query with join
const string orgName = "Apache";
- persons.Query(new SqlQuery(typeof(Person), "from Person, \"orgs-sql\".Organization where Person.OrgId = \"orgs-sql\".Organization._key and \"orgs-sql\".Organization.Name = ?", orgName))
+ persons.Query(new SqlFieldsQuery("select Person.name from Person, \"orgs-sql\".Organization where Person.OrgId = \"orgs-sql\".Organization._key and \"orgs-sql\".Organization.Name = ?", orgName))
.Dump("Persons working for " + orgName);
- // Fields query
- orgs.Query(new SqlFieldsQuery("select name, size from Organization")).Dump("Fields query");
-
// Full text query
persons.Query(new TextQuery(typeof(Person), "Chris*")).Dump("Persons starting with 'Chris'");
}
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs
index 0d96f4c..7a9a5b1 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Examples.Datagrid
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.ExamplesDll.Binary;
/// <summary>
/// This example works with cache entirely in binary mode: no classes or configurations are needed.
@@ -78,7 +79,7 @@ namespace Apache.Ignite.Examples.Datagrid
Fields = new[]
{
new QueryField(NameField, typeof(string)),
- new QueryField(CompanyIdField, typeof(int))
+ new QueryField(CompanyIdField, typeof(int)),
},
Indexes = new[]
{
@@ -117,9 +118,6 @@ namespace Apache.Ignite.Examples.Datagrid
// Run SQL query with join example.
SqlJoinQueryExample(cache);
- // Run SQL fields query example.
- SqlFieldsQueryExample(cache);
-
// Run full text query example.
FullTextQueryExample(cache);
@@ -153,18 +151,18 @@ namespace Apache.Ignite.Examples.Datagrid
}
/// <summary>
- /// Queries persons that have a specific name using SQL.
+ /// Queries names for all persons.
/// </summary>
/// <param name="cache">Cache.</param>
private static void SqlQueryExample(ICache<int, IBinaryObject> cache)
{
- var qry = cache.Query(new SqlQuery(PersonType, "name like 'James%'"));
+ var qry = cache.Query(new SqlFieldsQuery("select name from Person order by name"));
Console.WriteLine();
- Console.WriteLine(">>> Persons named James:");
+ Console.WriteLine(">>> All person names:");
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ foreach (var row in qry)
+ Console.WriteLine(">>> " + row[0]);
}
/// <summary>
@@ -175,9 +173,9 @@ namespace Apache.Ignite.Examples.Datagrid
{
const string orgName = "Apache";
- var qry = cache.Query(new SqlQuery(PersonType,
- "from Person, Company " +
- "where Person.CompanyId = Company.Id and Company.Name = ?", orgName)
+ var qry = cache.Query(new SqlFieldsQuery(
+ "select pers.Name from Person as pers, Company as comp where pers.CompanyId = comp.Id and comp.Name = ?",
+ orgName)
{
EnableDistributedJoins = true,
Timeout = new TimeSpan(0, 1, 0)
@@ -187,22 +185,7 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine(">>> Persons working for " + orgName + ":");
foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries names for all persons.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<int, IBinaryObject> cache)
- {
- var qry = cache.Query(new SqlFieldsQuery("select name from Person order by name"));
-
- Console.WriteLine();
- Console.WriteLine(">>> All person names:");
-
- foreach (var row in qry)
- Console.WriteLine(">>> " + row[0]);
+ Console.WriteLine(">>> " + entry[0]);
}
/// <summary>
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
index 9fb7921..20de310 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
@@ -81,9 +81,6 @@ namespace Apache.Ignite.Examples.Sql
// Run SQL query with distributed join example.
SqlDistributedJoinQueryExample(employeeCache);
- // Run SQL fields query example.
- SqlFieldsQueryExample(employeeCache);
-
Console.WriteLine();
}
@@ -100,13 +97,13 @@ namespace Apache.Ignite.Examples.Sql
{
const int zip = 94109;
- var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+ var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee where zip = ?", zip));
Console.WriteLine();
Console.WriteLine(">>> Employees with zipcode {0} (SQL):", zip);
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ foreach (var row in qry)
+ Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
}
/// <summary>
@@ -117,15 +114,15 @@ namespace Apache.Ignite.Examples.Sql
{
const string orgName = "Apache";
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, \"dotnet_cache_query_organization\".Organization " +
+ var qry = cache.Query(new SqlFieldsQuery(
+ "select Employee.name from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
Console.WriteLine();
Console.WriteLine(">>> Employees working for " + orgName + ":");
foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ Console.WriteLine(">>> " + entry[0]);
}
/// <summary>
@@ -136,8 +133,8 @@ namespace Apache.Ignite.Examples.Sql
{
const string orgName = "Apache";
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, \"dotnet_cache_query_organization\".Organization " +
+ var qry = cache.Query(new SqlFieldsQuery(
+ "select Employee.name from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
{
EnableDistributedJoins = true,
@@ -145,25 +142,10 @@ namespace Apache.Ignite.Examples.Sql
});
Console.WriteLine();
- Console.WriteLine(">>> Employees working for " + orgName + ":");
+ Console.WriteLine(">>> Employees working for " + orgName + " (distributed joins enabled):");
foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries names and salaries for all employees.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<int, Employee> cache)
- {
- var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employee names and their salaries:");
-
- foreach (var row in qry)
- Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
+ Console.WriteLine(">>> " + entry[0]);
}
/// <summary>
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/ThinClient/ThinClientSqlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/ThinClient/ThinClientSqlExample.cs
index c46c850..70b5176 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/ThinClient/ThinClientSqlExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/ThinClient/ThinClientSqlExample.cs
@@ -72,12 +72,9 @@ namespace Apache.Ignite.Examples.ThinClient
// Populate cache with sample data entries.
PopulateCache(cache);
- // Run SQL example.
- SqlQueryExample(cache);
+ // Run examples.
+ SqlExample(cache);
LinqExample(cache);
-
- // Run SQL fields query example.
- SqlFieldsQueryExample(cache);
LinqFieldsExample(cache);
}
@@ -87,20 +84,18 @@ namespace Apache.Ignite.Examples.ThinClient
}
/// <summary>
- /// Queries employees that have provided ZIP code in address.
+ /// Queries names and salaries for all employees.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void SqlQueryExample(ICacheClient<int, Employee> cache)
+ private static void SqlExample(ICacheClient<int, Employee> cache)
{
- const int zip = 94109;
-
- var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+ var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee"));
Console.WriteLine();
- Console.WriteLine(">>> Employees with zipcode {0} (SQL):", zip);
+ Console.WriteLine(">>> Employee names and their salaries (SQL):");
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ foreach (var row in qry)
+ Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
}
/// <summary>
@@ -125,22 +120,6 @@ namespace Apache.Ignite.Examples.ThinClient
Console.WriteLine(">>> " + qry.ToCacheQueryable().GetFieldsQuery().Sql);
}
-
- /// <summary>
- /// Queries names and salaries for all employees.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICacheClient<int, Employee> cache)
- {
- var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employee names and their salaries (SQL):");
-
- foreach (var row in qry)
- Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
- }
-
/// <summary>
/// Queries names and salaries for all employees.
/// </summary>
diff --git a/modules/platforms/dotnet/examples/dotnetcore/LinqExample.cs b/modules/platforms/dotnet/examples/dotnetcore/LinqExample.cs
index 1132eb8..4fc070b 100644
--- a/modules/platforms/dotnet/examples/dotnetcore/LinqExample.cs
+++ b/modules/platforms/dotnet/examples/dotnetcore/LinqExample.cs
@@ -49,10 +49,10 @@ namespace Apache.Ignite.Examples
Console.WriteLine(">>> Cache LINQ example started.");
var employeeCache = ignite.GetOrCreateCache<int, Employee>(
- new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+ new CacheConfiguration(EmployeeCacheName, new QueryEntity(typeof(Employee))));
var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
- new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+ new CacheConfiguration(EmployeeCacheNameColocated, new QueryEntity(typeof(Employee))));
var organizationCache = ignite.GetOrCreateCache<int, Organization>(
new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
diff --git a/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs b/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs
index 1fe6a74..0e1454b 100644
--- a/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs
+++ b/modules/platforms/dotnet/examples/dotnetcore/SqlExample.cs
@@ -49,10 +49,10 @@ namespace Apache.Ignite.Examples
Console.WriteLine(">>> Cache query example started.");
var employeeCache = ignite.GetOrCreateCache<int, Employee>(
- new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+ new CacheConfiguration(EmployeeCacheName, new QueryEntity(typeof(Employee))));
var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
- new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+ new CacheConfiguration(EmployeeCacheNameColocated, new QueryEntity(typeof(Employee))));
var organizationCache = ignite.GetOrCreateCache<int, Organization>(
new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
@@ -65,31 +65,46 @@ namespace Apache.Ignite.Examples
// Run SQL query example.
SqlQueryExample(employeeCache);
+ // Run SQL filter query example.
+ SqlFilterQueryExample(employeeCache);
+
// Run SQL query with join example.
SqlJoinQueryExample(employeeCacheColocated);
// Run SQL query with distributed join example.
SqlDistributedJoinQueryExample(employeeCache);
+ }
+
+ /// <summary>
+ /// Queries names and salaries for all employees.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlQueryExample(ICache<int, Employee> cache)
+ {
+ var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee"));
- // Run SQL fields query example.
- SqlFieldsQueryExample(employeeCache);
+ Console.WriteLine();
+ Console.WriteLine(">>> Employee names and their salaries:");
+
+ foreach (var row in qry)
+ Console.WriteLine($">>> [Name={row[0]}, salary={row[1]}{']'}");
}
/// <summary>
/// Queries employees that have specified salary.
/// </summary>
/// <param name="cache">Cache.</param>
- private static void SqlQueryExample(ICache<int, Employee> cache)
+ private static void SqlFilterQueryExample(ICache<int, Employee> cache)
{
const int minSalary = 10000;
- var qry = cache.Query(new SqlQuery(typeof(Employee), "salary > ?", minSalary));
+ var qry = cache.Query(new SqlFieldsQuery("select name from Employee where salary > ?", minSalary));
Console.WriteLine();
- Console.WriteLine($">>> Employees with salary > {minSalary} (SQL):");
+ Console.WriteLine($">>> Employees with salary > {minSalary}:");
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ foreach (var row in qry)
+ Console.WriteLine(">>> " + row[0]);
}
/// <summary>
@@ -100,15 +115,15 @@ namespace Apache.Ignite.Examples
{
const string orgName = "Apache";
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, \"dotnet_cache_query_organization\".Organization " +
+ var qry = cache.Query(new SqlFieldsQuery(
+ "select Employee.name from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
Console.WriteLine();
Console.WriteLine($">>> Employees working for {orgName}:");
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
+ foreach (var row in qry)
+ Console.WriteLine(">>> " + row[0]);
}
/// <summary>
@@ -119,8 +134,8 @@ namespace Apache.Ignite.Examples
{
const string orgName = "Apache";
- var qry = cache.Query(new SqlQuery("Employee",
- "from Employee, \"dotnet_cache_query_organization\".Organization " +
+ var qry = cache.Query(new SqlFieldsQuery(
+ "select Employee.name from Employee, \"dotnet_cache_query_organization\".Organization " +
"where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
{
EnableDistributedJoins = true
@@ -129,23 +144,8 @@ namespace Apache.Ignite.Examples
Console.WriteLine();
Console.WriteLine(">>> Employees working for " + orgName + " (distributed joins):");
- foreach (var entry in qry)
- Console.WriteLine(">>> " + entry.Value);
- }
-
- /// <summary>
- /// Queries names and salaries for all employees.
- /// </summary>
- /// <param name="cache">Cache.</param>
- private static void SqlFieldsQueryExample(ICache<int, Employee> cache)
- {
- var qry = cache.Query(new SqlFieldsQuery("select name, salary from Employee"));
-
- Console.WriteLine();
- Console.WriteLine(">>> Employee names and their salaries:");
-
- foreach (IList row in qry)
- Console.WriteLine($">>> [Name={row[0]}, salary={row[1]}{']'}");
+ foreach (var row in qry)
+ Console.WriteLine(">>> " + row[0]);
}
/// <summary>