Hi,
You have to use Ignite Binary Serialization to enable SQL queries [1].
To do that, remove [Serializable] attribute and register Employee class in
the configuration:
var cfg = new IgniteConfiguration
{
CacheConfiguration = new[]
{
new CacheConfiguration("mycache", typeof(Employee))
},
BinaryConfiguration = new
BinaryConfiguration(typeof(Employee))
};
[1] https://apacheignite-net.readme.io/docs/serialization
On Mon, Jul 4, 2016 at 1:21 PM, November <[email protected]> wrote:
> 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.
>