Что нового
  • Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

My Top 10 Aurelius Features - #5 Linq Expressions And Paging

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,071
Баллы
155
Возраст
51
Most examples and quick-start tutorials about ORM frameworks explain how to insert, update and retrieve single entities in the database. But not many of them go further and show how to perform a query in the database. Maybe because that's something that the developer will only need after many data is inserted, and it's something that is only heavily needed when the application development is at a more advanced stage. However, it's a very important feature, and that's why "LINQ Expressions and Paging" is my #5 feature of

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.



The reason for that is because you can really query your entities in a object-oriented way. It's not some SQL-like string you build, or SQL WHERE statement that you simply inject. It's really about querying object properties, comparing their values in Pascal (not in database), and using Pascal syntax to build the queries. Take a look at this example:



MyCustomers�:=�Manager.Find<TCustomer>
��.Where(
����(
(Linq['Birthday']�>�EncodeDate(1981,�10,�10))
���� and�(Linq['Birthday']�pre>
That's an example of filtering by Birthday property using logical operators "and", "or", how you can use parenthesis and have Delphi give you compile errors if expression is wrongly constructed. And of course you have extra expressions like "Contains", "In", etc.. All in Pascal.



Finally, a small feature of LINQ filtering that I enjoy a lot: paging. It's very simple to use and very handy:


MyCustomers�:=�Manager.Find<TCustomer>
.Take(10).Skip(50)
.OrderBy('Name')
�.List;


The code above in theory should bring all customers, but will only bring 10 customers, skipping the first 50 in the specified order. This is great for bringing a long list but in parts, page by page. And of course you can use it with any criteria you specify, like the complex one illustrated above in this post.



To see in details how LINQ expressions and paging works, watch the video above, and if you want to get notified about upcoming videos, subscribe to our

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх