|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-02-01 10:36:37
Posts: 101,
Visits: 751
|
|
I have just published ECO4 PersistenceMapper that lets you fetch objects from the store by SQL instead of OCL. It's not perfect but it works (six months in production). Please take a look at it and let me know what you think.
http://ecosqlcondition.codeplex.com/
/Pawel
|
|
|
|
|
Forum Guru
      
Group: Forum Members
Last Login: 2010-03-29 14:48:07
Posts: 71,
Visits: 303
|
|
where is the url to play with it
regards
Frank
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-02-01 10:36:37
Posts: 101,
Visits: 751
|
|
Sorry for the omission. I have added it to the original post.
/Pawel
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
Hi Pawel,
Looks very, very good! Great job.
One note. I think it would be better to implement this as an Eco Service, so it will be possible to run queries without having access to the EcoSpace itself.
Cheers,
Dmitriy.
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-02-01 10:36:37
Posts: 101,
Visits: 751
|
|
nagir (2009-07-01) Hi Pawel,
I think it would be better to implement this as an Eco Service, so it will be possible to run queries without having access to the EcoSpace itself.
The access to the ecospace is not needed. You only need IEcoServiceProvider to get the standard IPersistenceService implementation. For example
this.AsIObject().ServiceProvider.GetEcoService < IPersistenceService > ().GetAllWithCondition(sqlCondition);
/Pawel
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
Hi Pawel,
Sorry. I didn't pay attention to it. Just looking at the samples I though EcoSpace is required.
Now I have looked into the code. You probably spent a lot of time digging into ECO internals .
I think it would be reasonable to add a note somewhere on CodePlex (if it's not there) that that query should always return 2 mandatory columns: eco_id and eco_type.
So if the database has different structure than ECO generates by default, the SQL should look like:
-- Select persons that have costs and payments
SELECT p.PersonId AS eco_id, p.PersonType AS eco_type
FROM Person p
WHERE EXISTS (
SELECT 1 FROM Cost c, Payment pay WHERE c.CostId=pay.PaymentId AND c.PersonId=p.PersonId)
Also it worth to mention that the SQL only returns IDs and it cannot be used to load the objects themselves or execute aggregate calculations on the DB. This is just retrieve condition at the end of the day 
Another note is that I never store eco_type column in the DB unless required (hierarchy). So I don't have the eco_type at all (I always know the Address is Address or Country is a Country etc).
Not sure how I can make use of the SqlCondition in this case as I cannot return eco_type in this case.
Probably I need to push the parameter with the correct value from the EcoMapping like this:
SqlCondition sqlCondition = new SqlCondition(ecoSpace, typeof(BaseClass));
sqlCondition.Sql = "SELECT CountryId as eco_id, :type as eco_type FROM Country WHERE some condition";
sqlCondition.Parameters.Add(new EcoParameter("type", ecoSpace.GetTheClassIdFromMapping()));
IObjectList sqlResult = ecoSpace.Persistence.GetAllWithCondition(sqlCondition);
Anyway, that's a great work.
And bless your for sharing the code at CP.
Cheers,
Dmitriy.
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-27 18:06:44
Posts: 189,
Visits: 777
|
|
An excellent idea and I will try to take a look at it in the coming weeks.
I think we will have a minor problem for the future though, as it seems the IOclPsService interface has dropped CreateRetrieveCondition and other currently used methods from a quick look over your Getting Started article.
For the life of me I do not know why the existing methods seem to have been removed, as I've older code that uses them all over the place.
However, thank you again for sharing this with us. I'll try to test it in some existing ECO4 projects.
Kind regards, Scott
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2011-06-28 15:42:26
Posts: 487,
Visits: 1 277
|
|
Two questions.
1. Doesn't using sql re-introduce back-end to back-end differences in Sql?
2. What about Eco 5.
/mtiede
Environment:
Windows 7 Ultimate 64 bit
Delphi 6
Rad Studio 2010 Enterprise with Prism 2011
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-27 18:06:44
Posts: 189,
Visits: 777
|
|
It does indeed. However, as many people have pointed out before, there are somethings that OCL itself isn't that good with, or perhaps can be optomized by someone with sufficient knowledge.
Whilst this may introduce links to specific platform aspects, if I can limit the exposure as much as possible, that gives me only a small segment that will require change should another platform be adopted.
As far as I can see, the CreateRetrieveCondition and related method calls were removed from the IOclPsService interface in ECO5, yet I haven't seen that mentioned before in the release notes. I'm unsure why they decided to remove those in the eventually released version, and have emailed a few people to ask why as I know projects I will be wanting to migrate forward use that mechanism at the moment. I'm sure I won't be the only one with these issues facing them.
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-02-01 10:36:37
Posts: 101,
Visits: 751
|
|
Scott Price (2009-07-01)
As far as I can see, the CreateRetrieveCondition and related method calls were removed from the IOclPsService...
CreateRetrieveCondition is not used to create SqlCondition. The only function required is GetAllWithCondition() to "execute" the condition.
/Pawel
|
|
|
|