0
votes

I have to change the data type mapping for my custom query class (i am using FireDAC). This is no problem itself, i have already created a procedure that does the job. But i hit a wall while implementing it on a big scale. I have created a procedure in my class which gets the self.FormatOptions.MapRules property from it's database connection component (which has the right data type mapping rules). Now i wanna change my class so every component of that class executes my procedure OnOpen but i can't seem to find a way do assign a procedure to an event in a class.

Is there a way to do that or "inherit" that property from my database connection component when it's not the parent of my query component?

I already tried doing it with the constructor but since i don't create the query component in runtime, the constructor is not called

Since the query component is used some 500+ times in the project i don't wanna assign the procedure to the event every time by hand...

1
Well, map rules (actually all the settings, if not modified in the dataset objects) are already inherited from the assigned connection object. I see no reason to do anything here.Victoria
As Victoria said the map rules are already inherited. You will get better responses if you show your code that demonstrates the problem. It's not clear to me what you mean by "custom query class", and all objects - even components dropped on a form or data module call the constructor. You may need to consider overriding a specific method instead of trying to set an event handler, but that is just a guess without seeing any code.Mark Elder
@Victoria initially i thought that is should be like you proposed but I am/was confused bc i would get a access violation when i tried to access "dat.formatoptions.maprules.items[0]" (which is my query, the connection has it set properly in this case). So i started messing with "TMy(Queryclass)". i now put everything back to default in my "TMy(Queryclass)". By testing i found out that "ownmaprules" is set to true by heritage like it is supposed to. But it seems not the maprules.items, is this supposed to be like that or is it my misunderstanding of debugging heritated properties...?Paul
@Paul, sorry, but I have no idea about your class design. All I can say is that the behavior of inheritance is described in this help topic. In short, the lower you setup some option, the higher precedence it gets (or in other words, if you won't modify a certain settings option in a dataset level object, that option value will be inherited from the assigned connection, if you won't modify a certain settings option in connection object, it will be inherited from the global connection manager).Victoria

1 Answers

0
votes

OK, i just "solved" it. The problem was inside my class hirachy. It was like;

  • Top Layer : TMyCustomClass
  • Middle : TMygenerealClass
  • Bottom : TStandardClass

In The Middle class the default for Dataset.formatoptions.ownmaprules was set to true, which broke the heritage. Basically i had a lack of understanding how heritage works ;)