* * *

Author Topic: separating where, and order by causes into properties?  (Read 363 times)

mobilevil

  • New member
  • *
  • Posts: 35
    • http://www.kachun.com
separating where, and order by causes into properties?
« on: May 14, 2018, 03:04:16 am »
Hello,
my knowledge of delphi is mostly stuck in delphi 7 days... it is possible that it has been implemented somewhere.

do you guys think it is possible to separate the sort by and where causes into separated properties so that I can turn them on and off i run time easily?

e.g. to let the user choose which field to sort by, and the query condition.
in OnClick event of a grid:
dataset1.clearsort;
dataset1.sortby:=true
dataset1.sortby[i+1]:=true;//turn on two sort automatically

dataset1.turnoffallconditions;
dataset1.condition[1].active:=true;
dataset1.condition[1].priority=1st;
dataset1.condition[2].active:=true;
dataset1.condition[2].priority=or;//concat an OR in the final SQL for this condition

dataset1.restart;//there is no re-query command now?

at least we can reduce the redundancy of storing the SQL in the component for design time, and in run time, and it will be cool to use.

btw I am using IBX.
« Last Edit: May 14, 2018, 08:29:11 am by mobilevil »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7869
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: separating where, and order by causes into properties?
« Reply #1 on: May 14, 2018, 07:36:09 am »
Never seen on that implements this, which is somewhere in between TDataset and proper ORM/OPF. Should be possible (and relatively easy) just to subclass related TDataset, or make a class helper for TDataset instead so all existing TDataset descendants can get the benefit.

mobilevil

  • New member
  • *
  • Posts: 35
    • http://www.kachun.com
Re: separating where, and order by causes into properties?
« Reply #2 on: May 14, 2018, 08:52:39 am »
thanks. maybe I will try to modify IBX and get something working first, as I am not familiar with other databases...

maybe just make it simple, ORDER_BY and WHERE could be simple text based property with their own ACTIVE field. the data component will concat them before executing the query. so that we don't to mess with all kind of SQL servers.




Zoran

  • Hero Member
  • *****
  • Posts: 1220
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: separating where, and order by causes into properties?
« Reply #3 on: May 14, 2018, 09:43:48 am »
thanks. maybe I will try to modify IBX and get something working first, as I am not familiar with other databases...

I you work with IBX, it is worth getting tonyw's opinion on this (the member of this forum who maintains IBX for Lazarus).
You can send him private message, just invite him to see this thread.

It is worth knowing what he thinks about this option, because:
-- He might give you a good reason why it should not be included, then you can think better about it.
-- If he agrees with your idea, he might want to help you implementing it, plus he might want to include it in the original ibx components, so the whole community will benefit and it will save you from the hell of merging your changes every time you update ibx.

valdir.marcos

  • Sr. Member
  • ****
  • Posts: 365
Re: separating where, and order by causes into properties?
« Reply #4 on: May 15, 2018, 02:32:14 pm »
maybe I will try to modify IBX and get something working first, as I am not familiar with other databases...
IBX and SQLDB are mostly RAD DBAware strategies that you already seem to know.
tiOPF and mORMot are OOP ORM strategies.

If you can, try to learn about ORM, tiOPF and mORMot before you try to redesign IBX.


Just some links:
What way of interaction with database is better?
http://forum.lazarus.freepascal.org/index.php?topic=36287.0

tiOPF - Free, Open Source Object Persistence Framework for Free Pascal & Delphi
http://tiopf.sourceforge.net/

tiopf-mapper /demos/bom/person_bom.pas
https://searchcode.com/codesearch/view/27042803/

graemeg/tiopf
https://github.com/graemeg/tiopf

CRUD Sample
http://forum.lazarus.freepascal.org/index.php/topic,37893.msg256000.html#msg256000

Best database pool library?
http://forum.lazarus.freepascal.org/index.php/topic,40203.msg277751.html#msg277751



If you can read in Brazilian Portuguese:

Artigo Clube Delphi 105 - tiOPF na Prática
https://www.devmedia.com.br/artigo-clube-delphi-105-tiopf-na-pratica/17232

Artigo Clube Delphi 106 - tiOPF na Prática
https://www.devmedia.com.br/artigo-clube-delphi-106-tiopf-na-pratica/15835

Mapeamento Objeto / Relacional em Win32- Clube Delphi 121
https://www.devmedia.com.br/mapeamento-objeto-relacional-em-win32-clube-delphi-121/17978

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus