Page 1 of 1

TEntityQuery syntax

Posted: Tue 31 Mar 2020 20:14
by ketas
Hi,
i try to use entitydac and i would like to know if there are some info to Linq property of TEntityQuery
and how can i define fields for this query. In documentation there is information for LINQ syntax, but this is
not usable in this property. I found in this forum only one answer with something
like "from e in emp" , but i think that is not really enough. I would like to use components, not coding
queries in source code (only way used in demo). I used unidac with design of queries in design time
(Sql property of TUniQuery) and i would like use entitydac the same way. Thanks for answer. Vojslav

Re: TEntityQuery syntax

Posted: Fri 03 Apr 2020 11:22
by MaximG
To run LINQ queries with the TEntityQuery component, use the property TEntityQuery.LINQ : h[url]ttps://www.devart.com/entitydac/docs/devart.en ... y.linq.htm[/url]
For example, the below query selects particular fields from Emp table and returns them in sorted order:

Code: Select all

EntityQuery.LINQ.Text := 'From E In Emp OrderBy(E.EName) Select(E.EName, E.Job, E.Dept.DName)';
Refer to the official documentation for more information about constructing LINQ queries: https://docs.microsoft.com/en-us/dotnet ... using-linq
Note that EntityDAC supports only basic LINQ queries. You can find respective examples in the EntityDemo project, which is distributed with EntityDAC.