ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: IGNITE-7318 .NET: Move SQL examples to Sql namespace
Date Wed, 10 Jan 2018 12:11:38 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 67c2de0dc -> 610720b43


IGNITE-7318 .NET: Move SQL examples to Sql namespace

This closes #3333


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/610720b4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/610720b4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/610720b4

Branch: refs/heads/master
Commit: 610720b434a0fb6c5e0ce767bb4c86ab43f00598
Parents: 67c2de0
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Wed Jan 10 15:11:27 2018 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Wed Jan 10 15:11:27 2018 +0300

----------------------------------------------------------------------
 .../Examples/ExamplesTest.cs                    |   3 +-
 .../Apache.Ignite.Examples.csproj               |   5 +-
 .../Datagrid/LinqExample.cs                     | 341 -------------------
 .../Datagrid/QueryDmlExample.cs                 | 165 ---------
 .../Datagrid/QueryExample.cs                    | 177 +---------
 .../Apache.Ignite.Examples/Sql/LinqExample.cs   | 340 ++++++++++++++++++
 .../Apache.Ignite.Examples/Sql/SqlDmlExample.cs | 164 +++++++++
 .../Apache.Ignite.Examples/Sql/SqlExample.cs    | 297 ++++++++++++++++
 8 files changed, 807 insertions(+), 685 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 48e471f..90e8e0a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -28,6 +28,7 @@ namespace Apache.Ignite.Core.Tests.Examples
     using Apache.Ignite.Examples.Datagrid;
     using Apache.Ignite.Examples.Messaging;
     using Apache.Ignite.Examples.Misc;
+    using Apache.Ignite.Examples.Sql;
     using Apache.Ignite.Examples.ThinClient;
     using NUnit.Framework;
 
@@ -57,7 +58,7 @@ namespace Apache.Ignite.Core.Tests.Examples
         private static readonly Type[] NoDllExamples =
         {
             typeof(BinaryModeExample), typeof(NearCacheExample), typeof(PeerAssemblyLoadingExample),
-            typeof(ThinClientPutGetExample)
+            typeof(ThinClientPutGetExample), typeof(SqlExample), typeof(LinqExample), typeof(SqlDmlExample)
         };
 
         /** Config file path. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
index 0aaa249..6106ffd 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -52,6 +52,9 @@
     <Reference Include="System.Transactions" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Sql\LinqExample.cs" />
+    <Compile Include="Sql\SqlDmlExample.cs" />
+    <Compile Include="Sql\SqlExample.cs" />
     <Compile Include="ThinClient\ThinClientPutGetExample.cs" />
     <Compile Include="ThinClient\ThinClientQueryExample.cs" />
     <Compile Include="Compute\ClosureExample.cs" />
@@ -64,9 +67,7 @@
     <Compile Include="Datagrid\NearCacheExample.cs" />
     <Compile Include="Datagrid\OptimisticTransactionExample.cs" />
     <Compile Include="Datagrid\PutGetExample.cs" />
-    <Compile Include="Datagrid\LinqExample.cs" />
     <Compile Include="Datagrid\BinaryModeExample.cs" />
-    <Compile Include="Datagrid\QueryDmlExample.cs" />
     <Compile Include="Datagrid\QueryExample.cs" />
     <Compile Include="Datagrid\StoreExample.cs" />
     <Compile Include="Datagrid\TransactionDeadlockDetectionExample.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
deleted file mode 100644
index 1f8b71b..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/LinqExample.cs
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Examples.Datagrid
-{
-    using System;
-    using System.Linq;
-    using Apache.Ignite.Core;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cache.Affinity;
-    using Apache.Ignite.Core.Cache.Configuration;
-    using Apache.Ignite.Core.Cache.Query;
-    using Apache.Ignite.ExamplesDll.Binary;
-    using Apache.Ignite.Linq;
-
-    /// <summary>
-    /// This example populates cache with sample data and runs several LINQ queries over this data.
-    /// <para />
-    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
-    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
-    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
-    ///     Application -> Startup object);
-    /// 3) Start example (F5 or Ctrl+F5).
-    /// <para />
-    /// This example can be run with standalone Apache Ignite.NET node:
-    /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe:
-    /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
-    /// 2) Start example.
-    /// </summary>
-    public class LinqExample
-    {
-        /// <summary>Organization cache name.</summary>
-        private const string OrganizationCacheName = "dotnet_cache_query_organization";
-
-        /// <summary>Employee cache name.</summary>
-        private const string EmployeeCacheName = "dotnet_cache_query_employee";
-
-        /// <summary>Colocated employee cache name.</summary>
-        private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
-
-        [STAThread]
-        public static void Main()
-        {
-            using (var ignite = Ignition.StartFromApplicationConfiguration())
-            {
-                Console.WriteLine();
-                Console.WriteLine(">>> Cache LINQ example started.");
-
-                var employeeCache = ignite.GetOrCreateCache<int, Employee>(
-                    new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
-
-                var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
-                    new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
-
-                var organizationCache = ignite.GetOrCreateCache<int, Organization>(
-                    new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
-
-                // Populate cache with sample data entries.
-                PopulateCache(employeeCache);
-                PopulateCache(employeeCacheColocated);
-                PopulateCache(organizationCache);
-
-                // Run SQL query example.
-                QueryExample(employeeCache);
-
-                // Run compiled SQL query example.
-                CompiledQueryExample(employeeCache);
-
-                // Run SQL query with join example.
-                JoinQueryExample(employeeCacheColocated, organizationCache);
-
-                // Run SQL query with distributed join example.
-                DistributedJoinQueryExample(employeeCache, organizationCache);
-
-                // Run SQL fields query example.
-                FieldsQueryExample(employeeCache);
-
-                Console.WriteLine();
-            }
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Example finished, press any key to exit ...");
-            Console.ReadKey();
-        }
-
-        /// <summary>
-        /// Queries employees that have provided ZIP code in address.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void QueryExample(ICache<int, Employee> cache)
-        {
-            const int zip = 94109;
-
-            IQueryable<ICacheEntry<int, Employee>> qry =
-                cache.AsCacheQueryable().Where(emp => emp.Value.Address.Zip == zip);
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees with zipcode " + zip + ":");
-
-            foreach (ICacheEntry<int, Employee> entry in qry)
-                Console.WriteLine(">>>    " + entry.Value);
-        }
-
-        /// <summary>
-        /// Queries employees that have provided ZIP code in address with a compiled query.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void CompiledQueryExample(ICache<int, Employee> cache)
-        {
-            const int zip = 94109;
-
-            var cache0 = cache.AsCacheQueryable();
-
-            // Compile cache query to eliminate LINQ overhead on multiple runs.
-            Func<int, IQueryCursor<ICacheEntry<int, Employee>>> qry =
-                CompiledQuery.Compile((int z) => cache0.Where(emp => emp.Value.Address.Zip == z));
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees with zipcode {0} using compiled query:", zip);
-
-            foreach (ICacheEntry<int, Employee> entry in qry(zip))
-                Console.WriteLine(">>>    " + entry.Value);
-        }
-
-        /// <summary>
-        /// Queries employees that work for organization with provided name.
-        /// </summary>
-        /// <param name="employeeCache">Employee cache.</param>
-        /// <param name="organizationCache">Organization cache.</param>
-        private static void JoinQueryExample(ICache<AffinityKey, Employee> employeeCache,
-            ICache<int, Organization> organizationCache)
-        {
-            const string orgName = "Apache";
-
-            IQueryable<ICacheEntry<AffinityKey, Employee>> employees = employeeCache.AsCacheQueryable();
-            IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable();
-
-            IQueryable<ICacheEntry<AffinityKey, Employee>> qry =
-                from employee in employees
-                from organization in organizations
-                where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
-                select employee;
-
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees working for " + orgName + ":");
-
-            foreach (ICacheEntry<AffinityKey, Employee> entry in qry)
-                Console.WriteLine(">>>     " + entry.Value);
-        }
-
-        /// <summary>
-        /// Queries employees that work for organization with provided name.
-        /// </summary>
-        /// <param name="employeeCache">Employee cache.</param>
-        /// <param name="organizationCache">Organization cache.</param>
-        private static void DistributedJoinQueryExample(ICache<int, Employee> employeeCache,
-            ICache<int, Organization> organizationCache)
-        {
-            const string orgName = "Apache";
-
-            var queryOptions = new QueryOptions {EnableDistributedJoins = true};
-
-            IQueryable<ICacheEntry<int, Employee>> employees = employeeCache.AsCacheQueryable(queryOptions);
-            IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable(queryOptions);
-
-            IQueryable<ICacheEntry<int, Employee>> qry =
-                from employee in employees
-                from organization in organizations
-                where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
-                select employee;
-
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees working for " + orgName + ":");
-
-            foreach (ICacheEntry<int, Employee> entry in qry)
-                Console.WriteLine(">>>     " + entry.Value);
-        }
-
-        /// <summary>
-        /// Queries names and salaries for all employees.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void FieldsQueryExample(ICache<int, Employee> cache)
-        {
-            var qry = cache.AsCacheQueryable().Select(entry => new {entry.Value.Name, entry.Value.Salary});
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employee names and their salaries:");
-
-            foreach (var row in qry)
-                Console.WriteLine(">>>     [Name=" + row.Name + ", salary=" + row.Salary + ']');
-        }
-
-        /// <summary>
-        /// Populate cache with data for this example.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void PopulateCache(ICache<int, Organization> cache)
-        {
-            cache.Put(1, new Organization(
-                "Apache",
-                new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
-                OrganizationType.Private,
-                DateTime.Now));
-
-            cache.Put(2, new Organization(
-                "Microsoft",
-                new Address("1096 Eddy Street, San Francisco, CA", 94109),
-                OrganizationType.Private,
-                DateTime.Now));
-        }
-
-        /// <summary>
-        /// Populate cache with data for this example.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void PopulateCache(ICache<AffinityKey, Employee> cache)
-        {
-            cache.Put(new AffinityKey(1, 1), new Employee(
-                "James Wilson",
-                12500,
-                new Address("1096 Eddy Street, San Francisco, CA", 94109),
-                new[] {"Human Resources", "Customer Service"},
-                1));
-
-            cache.Put(new AffinityKey(2, 1), new Employee(
-                "Daniel Adams",
-                11000,
-                new Address("184 Fidler Drive, San Antonio, TX", 78130),
-                new[] {"Development", "QA"},
-                1));
-
-            cache.Put(new AffinityKey(3, 1), new Employee(
-                "Cristian Moss",
-                12500,
-                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
-                new[] {"Logistics"},
-                1));
-
-            cache.Put(new AffinityKey(4, 2), new Employee(
-                "Allison Mathis",
-                25300,
-                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
-                new[] {"Development"},
-                2));
-
-            cache.Put(new AffinityKey(5, 2), new Employee(
-                "Breana Robbin",
-                6500,
-                new Address("3960 Sundown Lane, Austin, TX", 78130),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(new AffinityKey(6, 2), new Employee(
-                "Philip Horsley",
-                19800,
-                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(new AffinityKey(7, 2), new Employee(
-                "Brian Peters",
-                10600,
-                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
-                new[] {"Development", "QA"},
-                2));
-        }
-
-        /// <summary>
-        /// Populate cache with data for this example.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void PopulateCache(ICache<int, Employee> cache)
-        {
-            cache.Put(1, new Employee(
-                "James Wilson",
-                12500,
-                new Address("1096 Eddy Street, San Francisco, CA", 94109),
-                new[] {"Human Resources", "Customer Service"},
-                1));
-
-            cache.Put(2, new Employee(
-                "Daniel Adams",
-                11000,
-                new Address("184 Fidler Drive, San Antonio, TX", 78130),
-                new[] {"Development", "QA"},
-                1));
-
-            cache.Put(3, new Employee(
-                "Cristian Moss",
-                12500,
-                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
-                new[] {"Logistics"},
-                1));
-
-            cache.Put(4, new Employee(
-                "Allison Mathis",
-                25300,
-                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
-                new[] {"Development"},
-                2));
-
-            cache.Put(5, new Employee(
-                "Breana Robbin",
-                6500,
-                new Address("3960 Sundown Lane, Austin, TX", 78130),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(6, new Employee(
-                "Philip Horsley",
-                19800,
-                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(7, new Employee(
-                "Brian Peters",
-                10600,
-                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
-                new[] {"Development", "QA"},
-                2));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs
deleted file mode 100644
index 00486bd..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryDmlExample.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Examples.Datagrid
-{
-    using System;
-    using Apache.Ignite.Core;
-    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 showcases DML capabilities of Ignite's SQL engine.
-    /// <para />
-    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
-    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
-    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
-    ///     Application -> Startup object);
-    /// 3) Start example (F5 or Ctrl+F5).
-    /// <para />
-    /// This example can be run with standalone Apache Ignite.NET node:
-    /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe:
-    /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
-    /// 2) Start example.
-    /// </summary>
-    public class QueryDmlExample
-    {
-        /// <summary>Organization cache name.</summary>
-        private const string OrganizationCacheName = "dotnet_cache_query_dml_organization";
-
-        /// <summary>Employee cache name.</summary>
-        private const string EmployeeCacheName = "dotnet_cache_query_dml_employee";
-
-        [STAThread]
-        public static void Main()
-        {
-            using (var ignite = Ignition.StartFromApplicationConfiguration())
-            {
-                Console.WriteLine();
-                Console.WriteLine(">>> Cache query DML example started.");
-
-                var employeeCache = ignite.GetOrCreateCache<int, Employee>(
-                    new CacheConfiguration(EmployeeCacheName, new QueryEntity(typeof(int), typeof(Employee))));
-
-                var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration(
-                    OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
-
-                employeeCache.Clear();
-                organizationCache.Clear();
-
-                Insert(organizationCache, employeeCache);
-                Select(employeeCache, "Inserted data");
-
-                Update(employeeCache);
-                Select(employeeCache, "Update salary for ASF employees");
-
-                Delete(employeeCache);
-                Select(employeeCache, "Delete non-ASF employees");
-
-                Console.WriteLine();
-            }
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Example finished, press any key to exit ...");
-            Console.ReadKey();
-        }
-
-        /// <summary>
-        /// Selects and displays Employee data.
-        /// </summary>
-        /// <param name="employeeCache">Employee cache.</param>
-        /// <param name="message">Message.</param>
-        private static void Select(ICache<int, Employee> employeeCache, string message)
-        {
-            Console.WriteLine("\n>>> {0}", message);
-
-            var qry = new SqlFieldsQuery(string.Format(
-                "select emp._key, emp.name, org.name, emp.salary " +
-                "from Employee as emp, " +
-                "\"{0}\".Organization as org " +
-                "where emp.organizationId = org._key", OrganizationCacheName))
-            {
-                EnableDistributedJoins = true
-            };
-
-            using (var cursor = employeeCache.Query(qry))
-            {
-                foreach (var row in cursor)
-                {
-                    Console.WriteLine(">>> {0}: {1}, {2}, {3}", row[0], row[1], row[2], row[3]);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Populate cache with test data.
-        /// </summary>
-        /// <param name="organizationCache">Organization cache.</param>
-        /// <param name="employeeCache">Employee cache.</param>
-        private static void Insert(ICache<int, Organization> organizationCache, ICache<int, Employee> employeeCache)
-        {
-            // Insert organizations.
-            var qry = new SqlFieldsQuery("insert into Organization (_key, name) values (?, ?)", 1, "ASF");
-            organizationCache.Query(qry);
-
-            qry.Arguments = new object[] {2, "Eclipse"};
-            organizationCache.Query(qry);
-
-            // Insert employees.
-            qry = new SqlFieldsQuery("insert into Employee (_key, name, organizationId, salary) values (?, ?, ?, ?)");
-
-            qry.Arguments = new object[] {1, "John Doe", 1, 4000};
-            employeeCache.Query(qry);
-
-            qry.Arguments = new object[] {2, "Jane Roe", 1, 5000};
-            employeeCache.Query(qry);
-
-            qry.Arguments = new object[] {3, "Mary Major", 2, 2000};
-            employeeCache.Query(qry);
-
-            qry.Arguments = new object[] {4, "Richard Miles", 2, 3000};
-            employeeCache.Query(qry);
-        }
-
-        /// <summary>
-        /// Conditional UPDATE query: raise salary for ASF employees.
-        /// </summary>
-        /// <param name="employeeCache">Employee cache.</param>
-        private static void Update(ICache<int, Employee> employeeCache)
-        {
-            var qry = new SqlFieldsQuery("update Employee set salary = salary * 1.1 where organizationId = ?", 1);
-
-            employeeCache.Query(qry);
-        }
-
-        /// <summary>
-        /// Conditional DELETE query: remove non-ASF employees.
-        /// </summary>
-        /// <param name="employeeCache">Employee cache.</param>
-        private static void Delete(ICache<int, Employee> employeeCache)
-        {
-            var qry = new SqlFieldsQuery(string.Format(
-                "delete from Employee where _key in (" +
-                "select emp._key from Employee emp, \"{0}\".Organization org " +
-                "where org.Name != ? and org._key = emp.organizationId)", OrganizationCacheName), "ASF");
-
-            employeeCache.Query(qry);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
index 23736ea..82bd72a 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -20,15 +20,13 @@ namespace Apache.Ignite.Examples.Datagrid
     using System;
     using Apache.Ignite.Core;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cache.Affinity;
     using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.ExamplesDll.Binary;
     using Apache.Ignite.ExamplesDll.Datagrid;
 
     /// <summary>
-    /// This example populates cache with sample data and runs several SQL and
-    /// full text queries over this data.
+    /// This example populates cache with sample data and runs Scan and Full-text queries.
     /// <para />
     /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
     ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
@@ -43,15 +41,9 @@ namespace Apache.Ignite.Examples.Datagrid
     /// </summary>
     public class QueryExample
     {
-        /// <summary>Organization cache name.</summary>
-        private const string OrganizationCacheName = "dotnet_cache_query_organization";
-
         /// <summary>Employee cache name.</summary>
         private const string EmployeeCacheName = "dotnet_cache_query_employee";
 
-        /// <summary>Employee cache name.</summary>
-        private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
-
         [STAThread]
         public static void Main()
         {
@@ -63,32 +55,12 @@ namespace Apache.Ignite.Examples.Datagrid
                 var employeeCache = ignite.GetOrCreateCache<int, Employee>(
                     new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
 
-                var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
-                    new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
-
-                var organizationCache = ignite.GetOrCreateCache<int, Organization>(
-                    new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
-
                 // Populate cache with sample data entries.
                 PopulateCache(employeeCache);
-                PopulateCache(employeeCacheColocated);
-                PopulateCache(organizationCache);
 
                 // Run scan query example.
                 ScanQueryExample(employeeCache);
 
-                // Run SQL query example.
-                SqlQueryExample(employeeCache);
-
-                // Run SQL query with join example.
-                SqlJoinQueryExample(employeeCacheColocated);
-
-                // Run SQL query with distributed join example.
-                SqlDistributedJoinQueryExample(employeeCache);
-
-                // Run SQL fields query example.
-                SqlFieldsQueryExample(employeeCache);
-
                 // Run full text query example.
                 FullTextQueryExample(employeeCache);
 
@@ -118,79 +90,6 @@ namespace Apache.Ignite.Examples.Datagrid
         }
 
         /// <summary>
-        /// Queries employees that have provided ZIP code in address.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void SqlQueryExample(ICache<int, Employee> cache)
-        {
-            const int zip = 94109;
-
-            var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees with zipcode {0} (SQL):", zip);
-
-            foreach (var entry in qry)
-                Console.WriteLine(">>>    " + entry.Value);
-        }
-
-        /// <summary>
-        /// Queries employees that work for organization with provided name.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void SqlJoinQueryExample(ICache<AffinityKey, Employee> cache)
-        {
-            const string orgName = "Apache";
-
-            var qry = cache.Query(new SqlQuery("Employee",
-                "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);
-        }
-
-        /// <summary>
-        /// Queries employees that work for organization with provided name.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void SqlDistributedJoinQueryExample(ICache<int, Employee> cache)
-        {
-            const string orgName = "Apache";
-
-            var qry = cache.Query(new SqlQuery("Employee",
-                "from Employee, \"dotnet_cache_query_organization\".Organization " +
-                "where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
-            {
-                EnableDistributedJoins = true
-            });
-
-            Console.WriteLine();
-            Console.WriteLine(">>> Employees working for " + orgName + ":");
-
-            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] + ']');
-        }
-
-        /// <summary>
         /// Queries employees that live in Texas using full-text query API.
         /// </summary>
         /// <param name="cache">Cache.</param>
@@ -209,80 +108,6 @@ namespace Apache.Ignite.Examples.Datagrid
         /// Populate cache with data for this example.
         /// </summary>
         /// <param name="cache">Cache.</param>
-        private static void PopulateCache(ICache<int, Organization> cache)
-        {
-            cache.Put(1, new Organization(
-                "Apache",
-                new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
-                OrganizationType.Private,
-                DateTime.Now));
-
-            cache.Put(2, new Organization("Microsoft",
-                new Address("1096 Eddy Street, San Francisco, CA", 94109),
-                OrganizationType.Private,
-                DateTime.Now));
-        }
-
-        /// <summary>
-        /// Populate cache with data for this example.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        private static void PopulateCache(ICache<AffinityKey, Employee> cache)
-        {
-            cache.Put(new AffinityKey(1, 1), new Employee(
-                "James Wilson",
-                12500,
-                new Address("1096 Eddy Street, San Francisco, CA", 94109),
-                new[] {"Human Resources", "Customer Service"},
-                1));
-
-            cache.Put(new AffinityKey(2, 1), new Employee(
-                "Daniel Adams",
-                11000,
-                new Address("184 Fidler Drive, San Antonio, TX", 78130),
-                new[] {"Development", "QA"},
-                1));
-
-            cache.Put(new AffinityKey(3, 1), new Employee(
-                "Cristian Moss",
-                12500,
-                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
-                new[] {"Logistics"},
-                1));
-
-            cache.Put(new AffinityKey(4, 2), new Employee(
-                "Allison Mathis",
-                25300,
-                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
-                new[] {"Development"},
-                2));
-
-            cache.Put(new AffinityKey(5, 2), new Employee(
-                "Breana Robbin",
-                6500,
-                new Address("3960 Sundown Lane, Austin, TX", 78130),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(new AffinityKey(6, 2), new Employee(
-                "Philip Horsley",
-                19800,
-                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
-                new[] {"Sales"},
-                2));
-
-            cache.Put(new AffinityKey(7, 2), new Employee(
-                "Brian Peters",
-                10600,
-                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
-                new[] {"Development", "QA"},
-                2));
-        }
-
-        /// <summary>
-        /// Populate cache with data for this example.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
         private static void PopulateCache(ICache<int, Employee> cache)
         {
             cache.Put(1, new Employee(

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/LinqExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/LinqExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/LinqExample.cs
new file mode 100644
index 0000000..9962b20
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/LinqExample.cs
@@ -0,0 +1,340 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Examples.Sql
+{
+    using System;
+    using System.Linq;
+    using Apache.Ignite.Core;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Affinity;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Query;
+    using Apache.Ignite.ExamplesDll.Binary;
+    using Apache.Ignite.Linq;
+
+    /// <summary>
+    /// This example populates cache with sample data and runs several LINQ queries over this data.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite.NET node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config
+    /// 2) Start example.
+    /// </summary>
+    public class LinqExample
+    {
+        /// <summary>Organization cache name.</summary>
+        private const string OrganizationCacheName = "dotnet_cache_query_organization";
+
+        /// <summary>Employee cache name.</summary>
+        private const string EmployeeCacheName = "dotnet_cache_query_employee";
+
+        /// <summary>Colocated employee cache name.</summary>
+        private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
+
+        [STAThread]
+        public static void Main()
+        {
+            using (var ignite = Ignition.StartFromApplicationConfiguration())
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache LINQ example started.");
+
+                var employeeCache = ignite.GetOrCreateCache<int, Employee>(
+                    new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+
+                var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
+                    new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+
+                var organizationCache = ignite.GetOrCreateCache<int, Organization>(
+                    new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
+
+                // Populate cache with sample data entries.
+                PopulateCache(employeeCache);
+                PopulateCache(employeeCacheColocated);
+                PopulateCache(organizationCache);
+
+                // Run SQL query example.
+                QueryExample(employeeCache);
+
+                // Run compiled SQL query example.
+                CompiledQueryExample(employeeCache);
+
+                // Run SQL query with join example.
+                JoinQueryExample(employeeCacheColocated, organizationCache);
+
+                // Run SQL query with distributed join example.
+                DistributedJoinQueryExample(employeeCache, organizationCache);
+
+                // Run SQL fields query example.
+                FieldsQueryExample(employeeCache);
+
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Queries employees that have provided ZIP code in address.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void QueryExample(ICache<int, Employee> cache)
+        {
+            const int zip = 94109;
+
+            IQueryable<ICacheEntry<int, Employee>> qry =
+                cache.AsCacheQueryable().Where(emp => emp.Value.Address.Zip == zip);
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees with zipcode " + zip + ":");
+
+            foreach (ICacheEntry<int, Employee> entry in qry)
+                Console.WriteLine(">>>    " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries employees that have provided ZIP code in address with a compiled query.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void CompiledQueryExample(ICache<int, Employee> cache)
+        {
+            const int zip = 94109;
+
+            var cache0 = cache.AsCacheQueryable();
+
+            // Compile cache query to eliminate LINQ overhead on multiple runs.
+            Func<int, IQueryCursor<ICacheEntry<int, Employee>>> qry =
+                CompiledQuery.Compile((int z) => cache0.Where(emp => emp.Value.Address.Zip == z));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees with zipcode {0} using compiled query:", zip);
+
+            foreach (ICacheEntry<int, Employee> entry in qry(zip))
+                Console.WriteLine(">>>    " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries employees that work for organization with provided name.
+        /// </summary>
+        /// <param name="employeeCache">Employee cache.</param>
+        /// <param name="organizationCache">Organization cache.</param>
+        private static void JoinQueryExample(ICache<AffinityKey, Employee> employeeCache,
+            ICache<int, Organization> organizationCache)
+        {
+            const string orgName = "Apache";
+
+            IQueryable<ICacheEntry<AffinityKey, Employee>> employees = employeeCache.AsCacheQueryable();
+            IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable();
+
+            IQueryable<ICacheEntry<AffinityKey, Employee>> qry =
+                from employee in employees
+                from organization in organizations
+                where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
+                select employee;
+
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+            foreach (ICacheEntry<AffinityKey, Employee> entry in qry)
+                Console.WriteLine(">>>     " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries employees that work for organization with provided name.
+        /// </summary>
+        /// <param name="employeeCache">Employee cache.</param>
+        /// <param name="organizationCache">Organization cache.</param>
+        private static void DistributedJoinQueryExample(ICache<int, Employee> employeeCache,
+            ICache<int, Organization> organizationCache)
+        {
+            const string orgName = "Apache";
+
+            var queryOptions = new QueryOptions {EnableDistributedJoins = true};
+
+            IQueryable<ICacheEntry<int, Employee>> employees = employeeCache.AsCacheQueryable(queryOptions);
+            IQueryable<ICacheEntry<int, Organization>> organizations = organizationCache.AsCacheQueryable(queryOptions);
+
+            IQueryable<ICacheEntry<int, Employee>> qry =
+                from employee in employees
+                from organization in organizations
+                where employee.Value.OrganizationId == organization.Key && organization.Value.Name == orgName
+                select employee;
+
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+            foreach (ICacheEntry<int, Employee> entry in qry)
+                Console.WriteLine(">>>     " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries names and salaries for all employees.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void FieldsQueryExample(ICache<int, Employee> cache)
+        {
+            var qry = cache.AsCacheQueryable().Select(entry => new {entry.Value.Name, entry.Value.Salary});
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employee names and their salaries:");
+
+            foreach (var row in qry)
+                Console.WriteLine(">>>     [Name=" + row.Name + ", salary=" + row.Salary + ']');
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<int, Organization> cache)
+        {
+            cache.Put(1, new Organization(
+                "Apache",
+                new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+                OrganizationType.Private,
+                DateTime.Now));
+
+            cache.Put(2, new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now));
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<AffinityKey, Employee> cache)
+        {
+            cache.Put(new AffinityKey(1, 1), new Employee(
+                "James Wilson",
+                12500,
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                new[] {"Human Resources", "Customer Service"},
+                1));
+
+            cache.Put(new AffinityKey(2, 1), new Employee(
+                "Daniel Adams",
+                11000,
+                new Address("184 Fidler Drive, San Antonio, TX", 78130),
+                new[] {"Development", "QA"},
+                1));
+
+            cache.Put(new AffinityKey(3, 1), new Employee(
+                "Cristian Moss",
+                12500,
+                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                new[] {"Logistics"},
+                1));
+
+            cache.Put(new AffinityKey(4, 2), new Employee(
+                "Allison Mathis",
+                25300,
+                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                new[] {"Development"},
+                2));
+
+            cache.Put(new AffinityKey(5, 2), new Employee(
+                "Breana Robbin",
+                6500,
+                new Address("3960 Sundown Lane, Austin, TX", 78130),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(new AffinityKey(6, 2), new Employee(
+                "Philip Horsley",
+                19800,
+                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(new AffinityKey(7, 2), new Employee(
+                "Brian Peters",
+                10600,
+                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+                new[] {"Development", "QA"},
+                2));
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<int, Employee> cache)
+        {
+            cache.Put(1, new Employee(
+                "James Wilson",
+                12500,
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                new[] {"Human Resources", "Customer Service"},
+                1));
+
+            cache.Put(2, new Employee(
+                "Daniel Adams",
+                11000,
+                new Address("184 Fidler Drive, San Antonio, TX", 78130),
+                new[] {"Development", "QA"},
+                1));
+
+            cache.Put(3, new Employee(
+                "Cristian Moss",
+                12500,
+                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                new[] {"Logistics"},
+                1));
+
+            cache.Put(4, new Employee(
+                "Allison Mathis",
+                25300,
+                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                new[] {"Development"},
+                2));
+
+            cache.Put(5, new Employee(
+                "Breana Robbin",
+                6500,
+                new Address("3960 Sundown Lane, Austin, TX", 78130),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(6, new Employee(
+                "Philip Horsley",
+                19800,
+                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(7, new Employee(
+                "Brian Peters",
+                10600,
+                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+                new[] {"Development", "QA"},
+                2));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlDmlExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlDmlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlDmlExample.cs
new file mode 100644
index 0000000..a37db76
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlDmlExample.cs
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Examples.Sql
+{
+    using System;
+    using Apache.Ignite.Core;
+    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 showcases DML capabilities of Ignite's SQL engine.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite.NET node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config
+    /// 2) Start example.
+    /// </summary>
+    public class SqlDmlExample
+    {
+        /// <summary>Organization cache name.</summary>
+        private const string OrganizationCacheName = "dotnet_cache_query_dml_organization";
+
+        /// <summary>Employee cache name.</summary>
+        private const string EmployeeCacheName = "dotnet_cache_query_dml_employee";
+
+        [STAThread]
+        public static void Main()
+        {
+            using (var ignite = Ignition.StartFromApplicationConfiguration())
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache query DML example started.");
+
+                var employeeCache = ignite.GetOrCreateCache<int, Employee>(
+                    new CacheConfiguration(EmployeeCacheName, new QueryEntity(typeof(int), typeof(Employee))));
+
+                var organizationCache = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration(
+                    OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
+
+                employeeCache.Clear();
+                organizationCache.Clear();
+
+                Insert(organizationCache, employeeCache);
+                Select(employeeCache, "Inserted data");
+
+                Update(employeeCache);
+                Select(employeeCache, "Update salary for ASF employees");
+
+                Delete(employeeCache);
+                Select(employeeCache, "Delete non-ASF employees");
+
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Selects and displays Employee data.
+        /// </summary>
+        /// <param name="employeeCache">Employee cache.</param>
+        /// <param name="message">Message.</param>
+        private static void Select(ICache<int, Employee> employeeCache, string message)
+        {
+            Console.WriteLine("\n>>> {0}", message);
+
+            var qry = new SqlFieldsQuery(string.Format(
+                "select emp._key, emp.name, org.name, emp.salary " +
+                "from Employee as emp, " +
+                "\"{0}\".Organization as org " +
+                "where emp.organizationId = org._key", OrganizationCacheName))
+            {
+                EnableDistributedJoins = true
+            };
+
+            using (var cursor = employeeCache.Query(qry))
+            {
+                foreach (var row in cursor)
+                {
+                    Console.WriteLine(">>> {0}: {1}, {2}, {3}", row[0], row[1], row[2], row[3]);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Populate cache with test data.
+        /// </summary>
+        /// <param name="organizationCache">Organization cache.</param>
+        /// <param name="employeeCache">Employee cache.</param>
+        private static void Insert(ICache<int, Organization> organizationCache, ICache<int, Employee> employeeCache)
+        {
+            // Insert organizations.
+            var qry = new SqlFieldsQuery("insert into Organization (_key, name) values (?, ?)", 1, "ASF");
+            organizationCache.Query(qry);
+
+            qry.Arguments = new object[] {2, "Eclipse"};
+            organizationCache.Query(qry);
+
+            // Insert employees.
+            qry = new SqlFieldsQuery("insert into Employee (_key, name, organizationId, salary) values (?, ?, ?, ?)");
+
+            qry.Arguments = new object[] {1, "John Doe", 1, 4000};
+            employeeCache.Query(qry);
+
+            qry.Arguments = new object[] {2, "Jane Roe", 1, 5000};
+            employeeCache.Query(qry);
+
+            qry.Arguments = new object[] {3, "Mary Major", 2, 2000};
+            employeeCache.Query(qry);
+
+            qry.Arguments = new object[] {4, "Richard Miles", 2, 3000};
+            employeeCache.Query(qry);
+        }
+
+        /// <summary>
+        /// Conditional UPDATE query: raise salary for ASF employees.
+        /// </summary>
+        /// <param name="employeeCache">Employee cache.</param>
+        private static void Update(ICache<int, Employee> employeeCache)
+        {
+            var qry = new SqlFieldsQuery("update Employee set salary = salary * 1.1 where organizationId = ?", 1);
+
+            employeeCache.Query(qry);
+        }
+
+        /// <summary>
+        /// Conditional DELETE query: remove non-ASF employees.
+        /// </summary>
+        /// <param name="employeeCache">Employee cache.</param>
+        private static void Delete(ICache<int, Employee> employeeCache)
+        {
+            var qry = new SqlFieldsQuery(string.Format(
+                "delete from Employee where _key in (" +
+                "select emp._key from Employee emp, \"{0}\".Organization org " +
+                "where org.Name != ? and org._key = emp.organizationId)", OrganizationCacheName), "ASF");
+
+            employeeCache.Query(qry);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/610720b4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
new file mode 100644
index 0000000..7222cfb
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Sql/SqlExample.cs
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Examples.Sql
+{
+    using System;
+    using Apache.Ignite.Core;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Affinity;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Query;
+    using Apache.Ignite.ExamplesDll.Binary;
+
+    /// <summary>
+    /// This example populates cache with sample data and runs SQL queries.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite.NET node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config
+    /// 2) Start example.
+    /// </summary>
+    public class SqlExample
+    {
+        /// <summary>Organization cache name.</summary>
+        private const string OrganizationCacheName = "dotnet_cache_query_organization";
+
+        /// <summary>Employee cache name.</summary>
+        private const string EmployeeCacheName = "dotnet_cache_query_employee";
+
+        /// <summary>Employee cache name.</summary>
+        private const string EmployeeCacheNameColocated = "dotnet_cache_query_employee_colocated";
+
+        [STAThread]
+        public static void Main()
+        {
+            using (var ignite = Ignition.StartFromApplicationConfiguration())
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache query example started.");
+
+                var employeeCache = ignite.GetOrCreateCache<int, Employee>(
+                    new CacheConfiguration(EmployeeCacheName, typeof(Employee)));
+
+                var employeeCacheColocated = ignite.GetOrCreateCache<AffinityKey, Employee>(
+                    new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee)));
+
+                var organizationCache = ignite.GetOrCreateCache<int, Organization>(
+                    new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));
+
+                // Populate cache with sample data entries.
+                PopulateCache(employeeCache);
+                PopulateCache(employeeCacheColocated);
+                PopulateCache(organizationCache);
+
+                // Run SQL query example.
+                SqlQueryExample(employeeCache);
+
+                // Run SQL query with join example.
+                SqlJoinQueryExample(employeeCacheColocated);
+
+                // Run SQL query with distributed join example.
+                SqlDistributedJoinQueryExample(employeeCache);
+
+                // Run SQL fields query example.
+                SqlFieldsQueryExample(employeeCache);
+
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Queries employees that have provided ZIP code in address.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlQueryExample(ICache<int, Employee> cache)
+        {
+            const int zip = 94109;
+
+            var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees with zipcode {0} (SQL):", zip);
+
+            foreach (var entry in qry)
+                Console.WriteLine(">>>    " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries employees that work for organization with provided name.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlJoinQueryExample(ICache<AffinityKey, Employee> cache)
+        {
+            const string orgName = "Apache";
+
+            var qry = cache.Query(new SqlQuery("Employee",
+                "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);
+        }
+
+        /// <summary>
+        /// Queries employees that work for organization with provided name.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlDistributedJoinQueryExample(ICache<int, Employee> cache)
+        {
+            const string orgName = "Apache";
+
+            var qry = cache.Query(new SqlQuery("Employee",
+                "from Employee, \"dotnet_cache_query_organization\".Organization " +
+                "where Employee.organizationId = Organization._key and Organization.name = ?", orgName)
+            {
+                EnableDistributedJoins = true
+            });
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+            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] + ']');
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<int, Organization> cache)
+        {
+            cache.Put(1, new Organization(
+                "Apache",
+                new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+                OrganizationType.Private,
+                DateTime.Now));
+
+            cache.Put(2, new Organization("Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now));
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<AffinityKey, Employee> cache)
+        {
+            cache.Put(new AffinityKey(1, 1), new Employee(
+                "James Wilson",
+                12500,
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                new[] {"Human Resources", "Customer Service"},
+                1));
+
+            cache.Put(new AffinityKey(2, 1), new Employee(
+                "Daniel Adams",
+                11000,
+                new Address("184 Fidler Drive, San Antonio, TX", 78130),
+                new[] {"Development", "QA"},
+                1));
+
+            cache.Put(new AffinityKey(3, 1), new Employee(
+                "Cristian Moss",
+                12500,
+                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                new[] {"Logistics"},
+                1));
+
+            cache.Put(new AffinityKey(4, 2), new Employee(
+                "Allison Mathis",
+                25300,
+                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                new[] {"Development"},
+                2));
+
+            cache.Put(new AffinityKey(5, 2), new Employee(
+                "Breana Robbin",
+                6500,
+                new Address("3960 Sundown Lane, Austin, TX", 78130),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(new AffinityKey(6, 2), new Employee(
+                "Philip Horsley",
+                19800,
+                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(new AffinityKey(7, 2), new Employee(
+                "Brian Peters",
+                10600,
+                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+                new[] {"Development", "QA"},
+                2));
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<int, Employee> cache)
+        {
+            cache.Put(1, new Employee(
+                "James Wilson",
+                12500,
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                new[] {"Human Resources", "Customer Service"},
+                1));
+
+            cache.Put(2, new Employee(
+                "Daniel Adams",
+                11000,
+                new Address("184 Fidler Drive, San Antonio, TX", 78130),
+                new[] {"Development", "QA"},
+                1));
+
+            cache.Put(3, new Employee(
+                "Cristian Moss",
+                12500,
+                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                new[] {"Logistics"},
+                1));
+
+            cache.Put(4, new Employee(
+                "Allison Mathis",
+                25300,
+                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                new[] {"Development"},
+                2));
+
+            cache.Put(5, new Employee(
+                "Breana Robbin",
+                6500,
+                new Address("3960 Sundown Lane, Austin, TX", 78130),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(6, new Employee(
+                "Philip Horsley",
+                19800,
+                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                new[] {"Sales"},
+                2));
+
+            cache.Put(7, new Employee(
+                "Brian Peters",
+                10600,
+                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+                new[] {"Development", "QA"},
+                2));
+        }
+    }
+}


Mime
View raw message