This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have the one entity named MyObject with next fields: Id, Name and Parent (typeof MyObject), Childrens (typeof EntityCollection<MyObject>) generated one-to-many association table structure is Id, Name, ParentId i want get all objects where Parent.Name = 'blabla' var Result = UnitOfWork.Find<MyObjects>(Entity.Attribute("Parent.Name")=="blabla"); this generate next SQL code SELECT
MyObject.ID AS "MyObject.ID", MyObject.ParentId AS "MyObject.ParentId", MyObject.Name AS "MyObject.Name" FROM MyObject WHERE (EXISTS ( SELECT MyObject.* FROM MyObject WHERE MyObject.ID = MyObject.ParentId AND mapObject.Name ='blabla' ) it always return null dataset but if i change it as SELECT
MyObject.ID AS "MyObject.ID", MyObject.ParentId AS "MyObject.ParentId", MyObject.Name AS "MyObject.Name" FROM MyObject WHERE (EXISTS ( SELECT R.* FROM MyObject R WHERE R.ID = MyObject.ParentId AND R.Name ='blabla' ) )
its work properly. how to solve this? Regards, Stanly.
|
|
|
You need to add some manual aliasing hints to the query to give it a better understanding about the self-join. Try this modification to your above query: UnitOfWork.Find<MyObjects>(Entity.Attribute(typeof(MyObjects), "R", "Parent.Name")=="blabla")
Jeremy |
|
|
Thanks for reply.
I`am try the next code
var Result = UnitOfWork.Find(Entity.Attribute(typeof(MyObject), "R", "Parent.Name") == "blabla");
...generated sql code
SELECT
MyObject.ID AS "MyObject.ID",
MyObject.ParentId AS "MyObject.ParentId",
MyObject.Name AS "MyObject.Name"
FROM
MyObject
WHERE
(EXISTS (
SELECT
MyObject.*
FROM
MyObject
WHERE
MyObject.ID = MyObject.ParentId AND
R.Name ='blabla')
it`s not work properly.
|
|
|
Can you send through a copy of your model and I will have a look into this further for you - that certainly looks incorrect :)
Thanks! Jeremy |
|
|
http://rapidshare.com/files/444389186/LS1.zip Thanks! |
|
|
Thanks! I have run the project up here and the query is running correctly (the EXISTS query is aliased as R, and the query returns the 3 children of the 'parent1' parent entity) so it looks like this may be something we have previously fixed and released as part of the nightly builds - can you grab the nightly build and recheck this.
Jeremy |
|
|
I have download the nightly build and trouble has gone. Thanks! |
|
|
I have downloaded the nightly build and trouble has gone. Thanks! |
|