ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From November <yufeng7...@126.com>
Subject .net configure sql query with c# code, when execute query, return empty set
Date Mon, 04 Jul 2016 10:21:32 GMT
Here is my code. Thanks.

namespace FirstIgnite
{
    class Program
    {
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                CacheConfiguration = new[]
                {
                    new CacheConfiguration("mycache", typeof(Employee))
                }
            };

            var ignite = Ignition.Start(cfg);

            var cache = ignite.GetCache<long, Employee>("mycache");

            Employee person1 = new Employee();
            person1.Age = 18;
            person1.Name = "yf";
            person1.Salary = 1000;

            Employee person2 = new Employee();
            person2.Age = 20;
            person2.Name = "sm";
            person2.Salary = 10000;

            cache.Put(1, person1);
            cache.Put(2, person2);

            var sql = new SqlQuery(typeof(Employee), "Salary > 10");

            var cursor = cache.Query(sql);
            
            foreach (var cacheEntry in cursor)
                Console.WriteLine("{0} | {1} | {2}", cacheEntry.Value.Age,
cacheEntry.Value.Name, cacheEntry.Value.Salary);
            
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }

    [Serializable]
    public class Employee
    {
        [QuerySqlField]
        public string Name { get; set; }

        [QuerySqlField]
        public long Salary { get; set; }

        [QuerySqlField]
        public int Age { get; set; }
    }
}



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/net-configure-sql-query-with-c-code-when-execute-query-return-empty-set-tp6069.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message