You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ptupitsyn (via GitHub)" <gi...@apache.org> on 2023/02/15 11:56:06 UTC

[GitHub] [ignite-3] ptupitsyn commented on a diff in pull request #1674: IGNITE-18793 Add public doc for LINQ

ptupitsyn commented on code in PR #1674:
URL: https://github.com/apache/ignite-3/pull/1674#discussion_r1107027995


##########
docs/_docs/thin-clients/linq.adoc:
##########
@@ -0,0 +1,540 @@
+= .NET LINQ Queries
+
+Apache Ignite .NET client provides LINQ support that is integrated with Ignite SQL APIs. You can avoid working with SQL syntax directly and write queries in C# with LINQ. C# LINQ expressions are then translated into Ignite-specific SQL. For example, the following two snippets achieve the same result:
+
+[tabs]
+--
+tab:LINQ[]
+[source, csharp]
+----
+var table = await Client.Tables.GetTableAsync("TBL1");
+IQueryable<Poco> query = table!.GetRecordView<Poco>().AsQueryable()
+    .Where(x => x.Key > 3)
+    .OrderBy(x => x.Key);
+List<Poco> queryResults = await query.ToListAsync();
+----
+
+tab:SQL[]
+[source, csharp]
+----
+var query = "select KEY, VAL from PUBLIC.TBL1 where (KEY > ?) order by KEY asc";
+await using IResultSet<IIgniteTuple> resultSet = await Client.Sql.ExecuteAsync(transaction: null, query, 3);
+var queryResults = new List<Poco>();
+await foreach (IIgniteTuple row in resultSet)
+{
+    queryResults.Add(new Poco { Key = (long)row[0]!, Val = (string?)row[1] });
+}
+----
+--
+
+LINQ has the following advantages over SQL:
+
+* Queries are strongly typed and checked at compilation;
+* It is easier to write and maintain with IDE support (auto-completion, navigation, find usages);
+* LINQ is refactoring-friendly: rename a column and all queries are updated at once;
+* Ignite-specific SQL knowledge is not required, and most C# developers are already familiar with LINQ;
+* LINQ is safe against SQL injections;
+* Results are mapped to types naturally.
+
+In real-world scenarios Apache Ignite LINQ queries are on par with equivalent SQL queries.

Review Comment:
   It is not clear that we talk about performance here (could be on par feature-wise or something else). We could start this sentence with "Performance-wise, ..."



##########
docs/_data/toc.yaml:
##########
@@ -46,7 +46,11 @@
 - title: REST API
   url: rest/rest-api
 - title: Thin Clients
-  url: thin-clients/index
+  items:
+    - title: Thin Clients Overview

Review Comment:
   There is no thick/thin client distinction in Ignite 3, all clients are "thin".
   The term "thin" can (and should) be omitted in documentation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org