Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 874A4200B30 for ; Mon, 4 Jul 2016 12:46:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 86107160A6D; Mon, 4 Jul 2016 10:46:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B1062160A55 for ; Mon, 4 Jul 2016 12:46:17 +0200 (CEST) Received: (qmail 31085 invoked by uid 500); 4 Jul 2016 10:46:16 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 31075 invoked by uid 99); 4 Jul 2016 10:46:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jul 2016 10:46:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 6A443180662 for ; Mon, 4 Jul 2016 10:46:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.279 X-Spam-Level: * X-Spam-Status: No, score=1.279 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gridgain-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 8L_05JmRD3GA for ; Mon, 4 Jul 2016 10:46:13 +0000 (UTC) Received: from mail-oi0-f52.google.com (mail-oi0-f52.google.com [209.85.218.52]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 1176A60CC6 for ; Mon, 4 Jul 2016 10:46:13 +0000 (UTC) Received: by mail-oi0-f52.google.com with SMTP id f189so189871117oig.3 for ; Mon, 04 Jul 2016 03:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gridgain-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=mzw6cvhGvE0IJGqf6JY0zlBEjNXTGaal6OPCDAxD7vQ=; b=nq5i/Kg6vvMSlqwCmuu4XH2Dgc77n4QNba2pI6pD5o/hvQC22IyX/caApu6HJcHFVA Aaw9YpmoFTz5cbnaAd2ADzb4Ti4pti7nCxuMP80oKAeExXZf3RmuM2zNvSezaKbn14MA aRMNpPCpbdo4TtpzAwZ70LQtEsCnB+KsU6ZVaF/dx1DwyhQyNITAiI0eew1i5y5hoBnu zjyo219YXGnWjMjL8sn1B3PfmZ3AN18RYb4jJT7TMtwRR+QVUmMDqv+UieWXa8x5gScV OKHkscXLgazaQXYstyd9POwP3mIKytORKtw0HAS0UoJaLn+zjwXDayGD2CRcgk6v0XqL AVmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=mzw6cvhGvE0IJGqf6JY0zlBEjNXTGaal6OPCDAxD7vQ=; b=PjzBl18zEi7dNr2VWnAdtNfI725jXcDwIBkbOmhNrPqwAAIYn50LCZYZadupX1O5pE VCRoTEeoTPzN0UqkoIMKonyDoMQ+VlXwgIXkzHd4zLkdpFMigkK/A51HrXyc4lTiTIDq LfpFtcxq1RL7PyuISv6GUNL3f75gZoSDIkB0z/ZzsQU1+D75xnKLxfIT2sTK1Cx5bjgI oh3V9/YobUL7HTD3j67lxugtgqN3tBJLqfYF5xOqJIuD06eaeU856xT4MxyjzjIeFz1L fcNsJbVFML+8uSyKi7TOIV7stARrhlQJpI0gRDchKbsKon5DgarO9q7PY89VvyNMpY3j 3SLw== X-Gm-Message-State: ALyK8tJ5ivmlIbyOps3N8BsTYcM7CjYUY0ZuIEQam59lIYSOM3j54m6XWrqySl1FVHUgesRJeIZNI7t8KGb1phjK X-Received: by 10.202.78.67 with SMTP id c64mr7024992oib.67.1467629171730; Mon, 04 Jul 2016 03:46:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.37.69 with HTTP; Mon, 4 Jul 2016 03:45:42 -0700 (PDT) In-Reply-To: <1467627692690-6069.post@n6.nabble.com> References: <1467627692690-6069.post@n6.nabble.com> From: Pavel Tupitsyn Date: Mon, 4 Jul 2016 13:45:42 +0300 Message-ID: Subject: Re: .net configure sql query with c# code, when execute query, return empty set To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=001a11c16a987181fa0536cd0b61 archived-at: Mon, 04 Jul 2016 10:46:18 -0000 --001a11c16a987181fa0536cd0b61 Content-Type: text/plain; charset=UTF-8 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 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("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. > --001a11c16a987181fa0536cd0b61 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

You have to use Ignite Binary Seria= lization to enable SQL queries [1].
To do that, remove [Serializa= ble] attribute and register Employee class in the configuration:
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 var cfg =3D new IgniteConfiguration
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 CacheConfiguration =3D new[]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 new CacheConfiguration("mycache", typeof(Employee))=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BinaryConfiguration =3D new Bina= ryConfiguration(typeof(Employee))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 };



On Mon, Jul 4, 2016 at 1:21 PM, November <yufeng7144@126= .com> wrote:
Here is my cod= e. Thanks.

namespace FirstIgnite
{
=C2=A0 =C2=A0 class Program
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 static void Main(string[] args)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var cfg =3D new IgniteConfigurati= on
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CacheConfiguration = =3D new[]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 new C= acheConfiguration("mycache", typeof(Employee))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 };

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var ignite =3D Ignition.Start(cfg= );

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

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Employee person1 =3D new Employee= ();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person1.Age =3D 18;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person1.Name =3D "yf";<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person1.Salary =3D 1000;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Employee person2 =3D new Employee= ();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person2.Age =3D 20;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person2.Name =3D "sm";<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 person2.Salary =3D 10000;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(1, person1);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(2, person2);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var sql =3D new SqlQuery(typeof(E= mployee), "Salary > 10");

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var cursor =3D cache.Query(sql);<= br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 foreach (var cacheEntry in cursor= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.WriteLine(&= quot;{0} | {1} | {2}", cacheEntry.Value.Age,
cacheEntry.Value.Name, cacheEntry.Value.Salary);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.WriteLine("Press any= key to exit");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.ReadKey();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }

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

=C2=A0 =C2=A0 =C2=A0 =C2=A0 [QuerySqlField]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public long Salary { get; set; }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 [QuerySqlField]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public int Age { get; set; }
=C2=A0 =C2=A0 }
}



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

--001a11c16a987181fa0536cd0b61--