Hi,

Your class is serialized with .NET BinaryFormatter, that's why SQL and LINQ
does not work [1].

To fix this, remove [Serializable] attribute and register the class in
BinaryConfiguration:


  var cfg = new IgniteConfiguration { BinaryConfiguration = new
BinaryConfiguration(typeof(MyModel) };
  using (var ignite = Ignition.Start(cfg))
  ...


[1] https://apacheignite-net.readme.io/docs/serialization

On Thu, Sep 22, 2016 at 6:15 AM, Murthy Kakarlamudi <ksa...@gmail.com>
wrote:

> Hi all,
>      I created a sample example based on the LINQExample provided in
> Ignite Examples. However I am not getting expected results. Any help is
> much appreciated. In my for loop at  the end I am expecting the last 10
> entries. But nothing is getting displayed. Any help is much appreciated.
>
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
> using Apache.Ignite.Core;
> using Apache.Ignite.Linq;
> using Apache.Ignite.Core.Cache;
> using Apache.Ignite.Core.Cache.Configuration;
> using Apache.Ignite.Core.Cache.Query;
>
> using MyIgnite;
>
> namespace MyIgniteConsole
> {
>     class Program
>     {
>         /// <summary>
>         ///
>         /// </summary>
>         /// <param name="args"></param>
>         static void Main(string[] args)
>         {
>             using (var ignite = Ignition.Start())
>             {
>                 Console.WriteLine();
>                 var cache = ignite.GetOrCreateCache<int, MyModel>(new
> CacheConfiguration
>                 {
>                     Name = "myCache",
>                     QueryEntities = new[]
>                     {
>                         new QueryEntity(typeof(int), typeof(MyModel))
>
>                     }
>                 });
>
>                 for (int i = 0; i < 100; i++)
>                 {
>                     cache.Put(i, new MyModel(i, "Test"));
>                 }
>
>                 Console.WriteLine("Cache size: "+cache.Get(10).MyKey);
>
>                 IQueryable<ICacheEntry<int, MyModel>> qry =
>                 cache.AsCacheQueryable().Where(obj => obj.Value.MyKey >
> 90);
>
>                 Console.WriteLine();
>                 Console.WriteLine(">>> Objects with Key greater than 90 "
> );
>
>                 foreach (ICacheEntry<int, MyModel> entry in qry)
>                     Console.WriteLine(">>>    " + entry.Value);
>
>                 Console.WriteLine();
>             }
>
>
>
>             Console.ReadLine();
>         }
>     }
> }
>
>
> *MyModel Class:*
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
> using Apache.Ignite.Core.Cache.Configuration;
>
> namespace MyIgniteConsole
> {
>     [Serializable]
>     class MyModel
>     {
>
>         public MyModel(int MyKeyIn, String MyStringIn)
>         {
>             MyKey = MyKeyIn;
>             MyString = MyStringIn;
>         }
>
>         [QuerySqlField]
>         public int MyKey { get; set; }
>
>         public String MyString { get; set; }
>     }
> }
>
>

Reply via email to