I have an application that exposes XData Aurelius functionality through TWebBroker server with one TXDataServerModule. Everything worked fine as long I had my entities and service contracts in "Default" model. I decided to specify model name in entities and service contracts because later I want to add second TXDataServerModule that will handle different database. However
After adding Model attribute to all entities and service contracts
After changing the TXDataServerModule creation to
lDataServerModule := TXDataServerModule.Create(
aBaseURI,
aConnectionPool, TXDataAureliusModel.get('MyModelName')
);
Recompiling server and client app.
Server returns error "URL http://...../// NOT FOUND
I am stuck here. What else should I do to make the whole thing work with a named model?
I have found that I forgot to tell the client to use named model. So I changed the TXDataClient creation to TXDataClient.Create(TXDataAureliusModel.get(MyModelName));
Also, I forgot to add
uses
Aurelius.Mapping.Attributes
to Service contracts units to enable Model attribute
Still does not work, now the error is "invalid query type "name of one of the entities""
Looks like despite the XDataClient was created with the MODEL argument,
the subsequent XDataClient..List< Entity class > call fails because the Query builder involved does not honour the XDataClient model and does not find the entity class belonging to the named model. HUH...
OK, I basically solved it. Looks like there is is a HUGE number of places that must be adjusted to support named model. Mostly because there is significant number of routines that have default Model = nil argument, which makes identifying necessary changes somewhat harder.
The first I came upon was ordinary function function CreateQuery(AModel: TXDataModel = nil): IXDataQueryBuilder;
which I use in several place in my code and now must be updated.
There are many others, but as I said can be done.
Consider the issue solved.