<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Wilson ORMapper Forums : OPath Queries</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=rss&amp;id=5&amp;key=gaVShzwrgFWlu0hEUA3QiA%3d%3d</link><description>Wilson ORMapper Forums : OPath Queries</description><item><title>Returning all object that not in a ManyToMany relationship</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2578&amp;key=eQp3q7WjLN65SFeAnyeOGw%3d%3d&amp;post=7759</link><pubDate>Thu, 08 Nov 2007 22:07:44 GMT</pubDate><description>When I use a query similar to the following:&lt;br&gt;&lt;br&gt;OPath&amp;lt;User&amp;gt;("!Group[1==1]")&lt;br&gt;&lt;br&gt;I get an exception saying that the not operator is only valid for boolean types.&amp;nbsp; Any idea what I might be doing wrong here or if there is a simple fix?&lt;br&gt;&lt;br&gt;Thanks!&lt;br&gt;</description></item><item><title>How to: convert OPath queries to database independent sqls</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2585&amp;key=A7wZdIPNJfaYKKhVHJ%2fjOg%3d%3d&amp;post=7738</link><pubDate>Fri, 14 Sep 2007 20:50:52 GMT</pubDate><description>&lt;P&gt;I have a few questions about convert OPath expressions to database independent sqls.&lt;/P&gt;
&lt;P&gt;Say you have the following sql:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;select field from table where fieldtwo='Value'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;I think the code would be somewhat like the following:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;helper&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt; = &lt;FONT color=#010001&gt;orEngine&lt;/FONT&gt;.&lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt;()&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;sql&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt;.&lt;FONT color=#010001&gt;Format&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"select {0} from {1} where {2}"&lt;/FONT&gt;, &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetFieldName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table.field"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetTableName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetExpression&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table.fieldtwo"&lt;/FONT&gt;, &lt;FONT color=#010001&gt;record&lt;/FONT&gt;.&lt;FONT color=#010001&gt;Code&lt;/FONT&gt;))&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;what I would rather do is:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;helper&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt; = &lt;FONT color=#010001&gt;orEngine&lt;/FONT&gt;.&lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt;()&lt;/P&gt;
&lt;P dir=ltr&gt;dim query as new OPathQuery(of Table)(table.fieldtwo="Value")&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;sql&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt;.&lt;FONT color=#010001&gt;Format&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"select {0} from {1} where {2}"&lt;/FONT&gt;, &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetFieldName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table.field"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetTableName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#010001&gt;query.???&lt;/FONT&gt;))&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;The old method would be:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt; &lt;/P&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;helper&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt; = &lt;FONT color=#010001&gt;orEngine&lt;/FONT&gt;.&lt;FONT color=#010001&gt;QueryHelper&lt;/FONT&gt;()&lt;/P&gt;
&lt;P dir=ltr&gt;dim query as new OPathQuery(of Table)(table.fieldtwo="Value")&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; &lt;FONT color=#010001&gt;sql&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;String&lt;/FONT&gt;.&lt;FONT color=#010001&gt;Format&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"select {0} from {1} where {2}"&lt;/FONT&gt;, &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetFieldName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table.field"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#010001&gt;helper&lt;/FONT&gt;.&lt;FONT color=#010001&gt;GetTableName&lt;/FONT&gt;(&lt;FONT color=#a31515&gt;"table"&lt;/FONT&gt;), &lt;FONT color=#010001&gt;_&lt;/P&gt;&lt;/FONT&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#010001&gt;helper.GetExpression("&amp;lt;OPath String&amp;gt;"&lt;/FONT&gt;))&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;The QueryHelper.GetExpression method that takes an OPathQuery object as it's parameter, is now marked as 'Obsolete'.&amp;nbsp; So what is the proper method to get a database independent sql clause from the OPath object?&amp;nbsp; I don't see any methods on the OPathQuery Object that would return the 'transformed' sql.&lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;The 'Obsolete' statement says:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#a31515 size=2&gt;Use the newer full OPath Engine instead -- see the OPathQuery and OPathQuery&amp;lt;T&amp;gt; classes.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#000000 size=3&gt;I am attempting to use above type of expressions in the ExecuteScalar method.&amp;nbsp; How is this done?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#000000 size=3&gt;Thanks&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#000000 size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;</description></item><item><title>Returning all object that not in a ManyToMany relationship</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2578&amp;key=eQp3q7WjLN65SFeAnyeOGw%3d%3d&amp;post=7724</link><pubDate>Thu, 30 Aug 2007 14:45:17 GMT</pubDate><description>&lt;P&gt;Imagine you were trying to you have a&amp;nbsp;simplistic&amp;nbsp;Users and Groups relationship where there is a ManyToMany expressed between users and groups. If you want to find all the Users that are not in any Groups what is the best OPath Query. &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;The best query I have found looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;OPath&amp;lt;User&amp;gt;("!Group[1==1]")&lt;/SPAN&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;How ever this seems to be counterintuitive and produces some verbose SQL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;This looks better but does not work because it results in a logically no-op SQL statement. &lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;OPath&amp;lt;User&amp;gt;("Group[!notNull(GroupID)]")&lt;/SPAN&gt; because it evaluates&amp;nbsp;the groups a user is in&amp;nbsp;before it calculates which one are not in groups. &lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;James&lt;/P&gt;&lt;/P&gt;</description></item><item><title>Querying child objects from same table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2569&amp;key=XM0PeAQMB9e28LIoTl61xA%3d%3d&amp;post=7711</link><pubDate>Tue, 21 Aug 2007 17:48:44 GMT</pubDate><description>&lt;P&gt;I found the &lt;A href="/Forums/Default.aspx?part=74&amp;amp;action=thread&amp;amp;id=1304&amp;amp;key=rBOwyBC6f4TZqGVMGwtitg%3d%3d"&gt;work around&lt;/A&gt;. It was easy to find once I discovered that this is referred to as an embedded object. The work around is to not use dot notation in the alias field:&lt;/P&gt;&lt;PRE&gt;&amp;lt;attribute member="address.line" field="AddressLine" alias="AddressLine" /&amp;gt;&lt;/PRE&gt;
&lt;P&gt;I can live with that.&lt;/P&gt;
&lt;P&gt;I know nothing about the OPath parser, but could it check the member field for dot notation and use that to recognize an embedded object?&lt;/P&gt;</description></item><item><title>Querying child objects from same table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2569&amp;key=XM0PeAQMB9e28LIoTl61xA%3d%3d&amp;post=7710</link><pubDate>Tue, 21 Aug 2007 17:17:40 GMT</pubDate><description>&lt;P&gt;Can anyone take a stab at this? I have inherited a database with the same address fields in many tables, and I'd like to represent them with an Address object. Normalizing isn't an option at this point.&lt;/P&gt;</description></item><item><title>Querying child objects from same table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2569&amp;key=XM0PeAQMB9e28LIoTl61xA%3d%3d&amp;post=7697</link><pubDate>Mon, 13 Aug 2007 18:23:08 GMT</pubDate><description>&lt;P&gt;I have a mapping similar to what Paul has posted in the examples, so I'll use his to illustrate my problem: &lt;PRE&gt;&amp;nbsp;&amp;lt;entity type="Contact" table="Contacts" keyMember="id" keyType="Auto"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sortOrder="ContactType DESC, ContactName ASC" typeField="ContactType" typeValue="?"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="id" field="ContactId" alias="Id" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="name" field="ContactName" alias="Name" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="address.line" field="AddressLine" alias="Address.Line" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="address.city" field="AddressCity" alias="Address.City" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="address.state" field="AddressState" alias="Address.Staet" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;attribute member="address.zip" field="AddressZip" alias="Address.Zip" /&amp;gt;&lt;/PRE&gt;
&lt;P&gt;Is it possible to write an OPath query for "Contact.Address.City='Boston'"? I receive the exception "Type 'VEIC.Mobile.Library.UserInfo' does not have a relationship named 'Audit' in the entity map." when trying to do something similar. I could throw a fake relationship in there to get it to work, but I'd rather not.&lt;/P&gt;
&lt;P&gt;Thanks, Jamie&lt;/P&gt;</description></item><item><title>OPathQuery TOP x</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2561&amp;key=fXxH%2ft8jUFlEfONtI3l6Iw%3d%3d&amp;post=7682</link><pubDate>Tue, 24 Jul 2007 17:36:22 GMT</pubDate><description>&lt;P&gt;I have implemented &lt;STRONG&gt;TOP x&lt;/STRONG&gt; for use with an OPathQuery.&amp;nbsp;&amp;nbsp;It's a&amp;nbsp;dirty hack and i'm &lt;STRONG&gt;not&lt;/STRONG&gt; proud of it.&amp;nbsp; It probably only works with MS SQL.&amp;nbsp; Again,its a dirty hack. If you'd like to see this hack let me know.&lt;/P&gt;
&lt;P&gt;Now onto implementing OPathQuery paging.... dont hold your breath.&lt;/P&gt;</description></item><item><title>One-to-many relationships with different number of key fields fails</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2558&amp;key=bMXrF7wM9KRWr3fBzq6ULQ%3d%3d&amp;post=7670</link><pubDate>Mon, 02 Jul 2007 21:17:35 GMT</pubDate><description>&lt;P&gt;The automatic relationship features expects both sides to be using the same number of fields as the parent's primary key.&amp;nbsp; If that is not the case, then you wil need to retrieve related records with&amp;nbsp;a query of your own construction.&lt;/P&gt;
&lt;P&gt;Thanks, Paul Wilson&lt;/P&gt;</description></item><item><title>One-to-many relationships with different number of key fields fails</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2558&amp;key=bMXrF7wM9KRWr3fBzq6ULQ%3d%3d&amp;post=7669</link><pubDate>Mon, 02 Jul 2007 20:04:33 GMT</pubDate><description>&lt;P&gt;Consider the following schema:&lt;/P&gt;
&lt;P&gt;create table CalendarDay (&lt;BR&gt;&amp;nbsp; year int, month int, days int,&lt;BR&gt;&amp;nbsp; constraint pk_calendarDays primary key ( year, month, day )&lt;BR&gt;)&lt;/P&gt;
&lt;P&gt;create table YearNote (&lt;BR&gt;&amp;nbsp; year int, note varchar(200),&lt;BR&gt;&amp;nbsp; constraint pk_yearNotes primary key ( year ),&lt;BR&gt;&amp;nbsp; constraint fk_yearCal foreign key ( year ) references calendarDays ( year )&lt;BR&gt;)&lt;/P&gt;
&lt;P&gt;Each CalendarDay has a one-to-many relationship with YearNote. However, the relation is based on a subset of CalendarDay's primary keys.&lt;/P&gt;
&lt;P&gt;This fails in the OPath query engine, which expects the number of primary key and foreign key fields to match. Obviously, the problem is not trivial -- how would the query parser know which fields to match in the case above?&lt;/P&gt;
&lt;P&gt;Does anyone have suggestions on how to work around this issue?&lt;/P&gt;</description></item><item><title>Bad SQL being returned by an OPath query.</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2509&amp;key=OdtU2Y2xlpJwxcLyMLjgVQ%3d%3d&amp;post=7577</link><pubDate>Tue, 01 May 2007 23:18:16 GMT</pubDate><description>&lt;P&gt;Thank you Jeff on your detailed reply; all points are noted and many are salient.&lt;/P&gt;
&lt;P&gt;I would point out that this code came from my unit test that I have written for entity/domain mapping purposes (and to learn more about the ORMapper).&lt;/P&gt;
&lt;P&gt;Regarding the ID column fields (i.e CarePackageID, PaperworkID), these are actually protected field's (that map directly to the ObjectHolder key member), as from an entity perspective they are non-sensical; and are there purely for implementation purposes only (i.e. WilsonORMapper). In my object domain, navigation is accomplished via object traversal alone. When an object is not lazy loaded then I don't actually reference these fields in the objects. Yes I appreciate that at times this may result in less than optimal performance, but if this come's and issue then I may well revisit the above.&lt;/P&gt;
&lt;P&gt;As a side note I did try to access those members when protected, but if my memory holds true, you only expect public properties (which is sensible enough).&lt;/P&gt;
&lt;P&gt;I do like the parameterize query comment though, wasn't aware that this was possible using oPath, I guess it may be worth me reading all the literature available on this Wilson stuff ;-)&lt;/P&gt;
&lt;P&gt;I have moved on from that point, and had a holiday in between, when I have accomplished my next task I will look at the mappings to determine if they are as expected.&lt;/P&gt;
&lt;P&gt;A big thank for your help here and for your contributions to the ORMapper.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Stephen Smith&lt;/P&gt;</description></item><item><title>Bad SQL being returned by an OPath query.</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2509&amp;key=OdtU2Y2xlpJwxcLyMLjgVQ%3d%3d&amp;post=7571</link><pubDate>Thu, 12 Apr 2007 22:58:32 GMT</pubDate><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Thanks for your detailed post.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;First, a couple things in terms of “best practices” with regard to how the query is setup and executed:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;In your query, I noticed you are traveling to related tables unnecessarily to test the column values.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example rather than traversing the CarePackage table to test the PK column, you could just test the FK column on your root table.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Same for the Paperwork table.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, the original query:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Arial','sans-serif'"&gt;"CarePackage.ID == '{0}' AND Paperwork.ID == '{1}'"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;, inserted.CarePackage.ID, inserted.Paperwork.ID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;could be simplified/optimized down to something like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Arial','sans-serif'"&gt;"CarePackageID == '{0}' AND PaperworkID == '{1}'"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;, inserted.CarePackage.ID, inserted.Paperwork.ID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Also note that we can optimize the parameters used in the string format:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Arial','sans-serif'"&gt;"CarePackageID == '{0}' AND PaperworkID == '{1}'"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;, inserted.CarePackageID, inserted.PaperworkID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;These two things are small changes in terms of the character count, but it can have a very positive impact on performance since (a) you avoid lazing loading two objects in order to get their ID values, and (b) you reduce the query to one that only involves a single table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Going a step farther, we can “parameterize” the query to remove the string building via string.Format():&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Arial','sans-serif'"&gt;"CarePackageID == ? AND PaperworkID == ?"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;The parameter values are passed when the query is executed:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;manager.GetObjectSet(query, inserted.CarePackageID, inserted.PaperworkID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Doing this causes OPath to produce a parameterized SQL statement, which makes it a LOT easier for SQL to reuse the execute plan.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’ve read that SQL Server (assuming that’s what your use) will internally parameterize a query in the hopes of not having to build a new plan every time, but I haven’t tested this to verify.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Either way, I can’t imagine it being as fast as query that already contains the parameters.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Anyway, enough on that.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Now, regarding the suspected bug in the generated SQL statement: &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;I’m not yet convinced it’s actually a bug in the OPath engine.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I think the bug is in the mapping file.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The “CarePackage” relationship in has the “PaperworkID” column specified as the key field:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Arial','sans-serif'"&gt;relation&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;relationship&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;ManyToOne&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;member&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;fCarePackage&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;field&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;PaperworkID&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;" &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;type&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;Smithfield.AGCare.CarePackage&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;alias&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;CarePackage&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;lazyLoad&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt;true&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Because this is the ManyToOne relation, that field is referring to the FK on the CarePackagePaperwork table.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As least I’m pretty sure it dones.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If I’m right about that, then the relationship is relating the PK of the CarePackage table (e.g., the CarePackageID column) to the PaperworkID column of the CarePackagePaperwork table.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’m guessing this is not what you actually want.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If this mapping file was auto-generated (how many aren’t these days), than it would mean the bug is in the map generator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Check the relationship in the database to make sure it’s correct (been there one too many times), then check your code generator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Try that and let me know if you can’t track down the source of the problem and it still looks the OPath Engine is to blame.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Thanks,&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri&gt;Jeff Lanning&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;</description></item><item><title>Bad SQL being returned by an OPath query.</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2509&amp;key=OdtU2Y2xlpJwxcLyMLjgVQ%3d%3d&amp;post=7569</link><pubDate>Wed, 11 Apr 2007 10:39:44 GMT</pubDate><description>&lt;P&gt;Background:&lt;/P&gt;
&lt;P&gt;ORMapper release date 4/11/2006.&lt;/P&gt;
&lt;P&gt;I have three entity objects, a CarePackage, Paperwork and a joining table/entity CarePackagePaperwork, that is composite Key'd on CarePackageID and PaperworkID.&lt;/P&gt;
&lt;P&gt;The mapping file looks like the following (CarePackagePaperwork):&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;!--&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt; CAREPACKAGEPAPERWORK &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;--&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;entity&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Smithfield.AGCare.CarePackagePaperwork&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;table&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackagePaperwork&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;keyMember&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackageID,PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;keyType&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Composite&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;attribute&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackageID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackageID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackageID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;oledbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WChar&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;cstype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;vbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;attribute&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;oledbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WChar&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;cstype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;vbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;attribute&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;fRecievedDate&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;RecievedDate&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;RecievedDate&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;oledbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DBTimeStamp&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;cstype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;vbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Date&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;attribute&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;fIsValid&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;IsValid&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;IsValid&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;oledbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Boolean&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;cstype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;vbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Boolean&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;attribute&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;fCommunicationMedium&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CommunicationMedium&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CommunicationMedium&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;oledbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WChar&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;cstype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;vbtype&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;relation&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;relationship&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ManyToOne&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;fCarePackage&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Smithfield.AGCare.CarePackage&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CarePackage&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;lazyLoad&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;relation&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;relationship&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ManyToOne&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;fPaperwork&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PaperworkID&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Smithfield.AGCare.Paperwork&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;alias&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Paperwork&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;lazyLoad&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;entity&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;(If required I can post/email mappings for all entities and class files)&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;U&gt;Problem:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;I use the following opath string&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;.Format(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CarePackage.ID == '{0}' AND Paperwork.ID = '{1}'"&lt;/FONT&gt;&lt;FONT size=2&gt;, inserted.CarePackage.ID,&lt;/P&gt;
&lt;P&gt;inserted.Paperwork.ID))&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;And invoke the opath query like this&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ObjectSpace&lt;/FONT&gt;&lt;FONT size=2&gt; manager = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PersistencyManager&lt;/FONT&gt;&lt;FONT size=2&gt;.Mapper;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OPathQuery&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;CarePackagePaperwork&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt;&lt;/FONT&gt;query = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;OPathQuery&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;FONT color=#2b91af&gt;CarePackagePaperwork&lt;/FONT&gt;&amp;gt;(opath);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; manager.GetObjectSet(query);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;The return is always NULL and when viewing the SQL generated from the above it is:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Select: SELECT a.[CarePackageID], a.[PaperworkID], a.[RecievedDate], a.[IsValid], a.[CommunicationMedium]&lt;BR&gt;FROM [CarePackagePaperwork] a&lt;BR&gt;WHERE (EXISTS&lt;BR&gt;(&lt;BR&gt;SELECT *&lt;BR&gt;FROM [CarePackage] b&lt;BR&gt;WHERE (a.[PaperworkID] = b.[CarePackageID]) AND (b.[CarePackageID] = 'TESTTE0711')&lt;BR&gt;) AND EXISTS&lt;BR&gt;(&lt;BR&gt;SELECT *&lt;BR&gt;FROM [Paperwork] c&lt;BR&gt;WHERE (a.[PaperworkID] = c.[PaperworkID]) AND (c.[PaperworkID] = 'Test')&lt;BR&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;If you view the sql carefully you will spot the line:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;FONT color=#0000ff size=2&gt;WHERE (a.[PaperworkID] = b.[CarePackageID]) AND (b.[CarePackageID] = 'TESTTE0711')&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;This is obviously wrong and should read!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;FONT color=#0000ff size=2&gt;WHERE (a.[&lt;U&gt;CarePackageID&lt;/U&gt;] = b.[CarePackageID]) AND (b.[CarePackageID] = 'TESTTE0711')&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;Any help you can provide would be very helpful!&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;Regards&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Stephen Smith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Smithfield Solutions Ltd&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description></item><item><title>Performing Group By</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2499&amp;key=%2b5w0%2fWjh8C2UsR8HbTmaLQ%3d%3d&amp;post=7539</link><pubDate>Tue, 27 Mar 2007 18:48:40 GMT</pubDate><description>You can't do group by clauses through the O/R mapper. You can use a stored procedure or view to expose your data. Add the locationid to the resultset and load entity objects based on those values.</description></item><item><title>Performing Group By</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2499&amp;key=%2b5w0%2fWjh8C2UsR8HbTmaLQ%3d%3d&amp;post=7521</link><pubDate>Sun, 25 Mar 2007 22:23:11 GMT</pubDate><description>&amp;nbsp;&amp;nbsp;&amp;nbsp; Hello Guys,&lt;br&gt;&lt;br&gt;Please Help me out as to How would I use the ORMapper to Generate a Query Below. The query gives me the Top 5 locations where the Live Jobs are posted. &lt;br&gt;&lt;br&gt;&lt;br&gt;select Top 5 count(*) as [LocationCount],ss_location.name as [Name]&amp;nbsp; from ss_job &lt;br&gt;inner join SS_location on&lt;br&gt;ss_location.id=ss_job.Locationid&lt;br&gt;where ss_job.active=1 and DateExpired&amp;gt;Getdate()&lt;br&gt;group by [Name] order by [LocationCount] DESC&lt;br&gt;&lt;br&gt;&lt;br&gt;Thank you,&lt;br&gt;&lt;br&gt;Rahul Sharma.&lt;br&gt;</description></item><item><title>Checking Many-to-One Relation For Missing Relation</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2479&amp;key=2zSoQX5vvRWS9egwR1RbQg%3d%3d&amp;post=7508</link><pubDate>Thu, 15 Mar 2007 06:00:02 GMT</pubDate><description>&lt;P&gt;The EXISTS keyword can be used to test for records in a related table... but it's not in the demo version of WORM.&amp;nbsp; I need to get with Paul and get a new release published that has support for this.&lt;/P&gt;
&lt;P&gt;However, since you are going from many-to-one you probably don't need to use EXISTS and can instead just test the FK column for null.&amp;nbsp; Something like the following might work:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;OPathQuery&amp;lt;Transaction&amp;gt;("IsNull(SubjectMatterExpertId)")&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;BR&gt;Jeff Lanning&lt;/P&gt;</description></item><item><title>Checking Many-to-One Relation For Missing Relation</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2479&amp;key=2zSoQX5vvRWS9egwR1RbQg%3d%3d&amp;post=7476</link><pubDate>Tue, 13 Mar 2007 19:56:53 GMT</pubDate><description>&lt;P&gt;During evaluation of the demo, I am testing how to check if a relation exists.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;I have an entity (Transaction) and an entity (SubjectMatterExpert).&amp;nbsp; Transactions are assigned to SubjectMatterExperts with a Many-to-One relation.&amp;nbsp; Everything is working fine with loading and persisting.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;What I want to do is use the OPathQuery.GetList&amp;lt;Transaction&amp;gt; to retrieve a list of Transactions that are not assigned to a SubjectMatterExpert (i.e. SubjectMatterExpertId is null).&amp;nbsp; I do not want to expose the internal member (_subjectMatterExpertId) to the consumers of my objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;I feel like I'm missing the obvious, but after searching the forums, I haven't come up with a solution.&amp;nbsp; If OpathQuery won't do it, please tell me what will.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:City w:st="on"&gt;&lt;st1:place w:st="on"&gt;Tracy&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>How to determine if child records exist</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2423&amp;key=kR%2bMEY5GkFYRrMxkks9EIQ%3d%3d&amp;post=7489</link><pubDate>Tue, 13 Mar 2007 19:56:27 GMT</pubDate><description>&lt;P&gt;Hi Jeff,&lt;/P&gt;
&lt;P&gt;I am also working with OPath since a while. Some time ago, we had some contact in this forum, therefore I am also interested in the latest version of the OPath Engine&lt;/P&gt;
&lt;P&gt;Could you mail it to me&lt;/P&gt;
&lt;P&gt;&lt;A href="mailto:stefan.roesch@wega-informatik.ch"&gt;stefan.roesch@wega-informatik.ch&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks and regards&lt;/P&gt;
&lt;P&gt;Stefan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Update multiple records</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2477&amp;key=T5QhN%2bABQ7QklUs4AH39nw%3d%3d&amp;post=7500</link><pubDate>Tue, 13 Mar 2007 19:52:45 GMT</pubDate><description>&lt;P&gt;I'm not sure if OPath gives you anything to help with batch updates, but there is an ExecuteUpdate method that may be good enough for you.&lt;/P&gt;
&lt;P&gt;Thanks, Paul Wilson&lt;/P&gt;</description></item><item><title>Update multiple records</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2477&amp;key=T5QhN%2bABQ7QklUs4AH39nw%3d%3d&amp;post=7472</link><pubDate>Tue, 13 Mar 2007 19:51:55 GMT</pubDate><description>&lt;P&gt;I am trying to build a query to update many records according to a specific WHERE clause.&lt;/P&gt;
&lt;P&gt;Icannot find any examples on such thing.&lt;/P&gt;
&lt;P&gt;can you please help me?&lt;/P&gt;</description></item><item><title>Using A Lookup Property In A Query</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2457&amp;key=Hc27qnWTMZOD4IP8WkNGwQ%3d%3d&amp;post=7454</link><pubDate>Thu, 08 Feb 2007 21:01:47 GMT</pubDate><description>&lt;P&gt;I probably will just need the entity node&amp;nbsp;containing that lookup field, but you never know.&amp;nbsp; You could post your entity here if you want, or just email me the whole mapping file.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR&gt;Jeff Lanning&lt;/P&gt;</description></item><item><title>Using A Lookup Property In A Query</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2457&amp;key=Hc27qnWTMZOD4IP8WkNGwQ%3d%3d&amp;post=7446</link><pubDate>Wed, 07 Feb 2007 00:12:29 GMT</pubDate><description>&lt;P&gt;I have tried placing the traversal outside the isnull function and it has the same effect (I noticed that solution in another post).&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Do you want me to send you my entire mapping file to an email address or post it here?&amp;nbsp; Or do you just want part.&amp;nbsp;It's kinda large.&lt;/P&gt;</description></item><item><title>Using A Lookup Property In A Query</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2457&amp;key=Hc27qnWTMZOD4IP8WkNGwQ%3d%3d&amp;post=7444</link><pubDate>Mon, 05 Feb 2007 04:14:23 GMT</pubDate><description>&lt;P&gt;Have you made any progress on this issue?&amp;nbsp; If not, could you send me a bit more of your mapping file?&amp;nbsp; I don’t use lookup fields very often so this could easily be a bug.&lt;/P&gt;
&lt;P&gt;One thing to try in the mean time is to place the traversal outside the isnull (e.g., &lt;FONT face="Courier New" color=#008000&gt;design[isnull(orderStatus)]&lt;/FONT&gt; ).&amp;nbsp; The expression you are using may not be valid and could be causing a error much farther down the pipe.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR&gt;Jeff&lt;BR&gt;&lt;/P&gt;</description></item><item><title>Using A Lookup Property In A Query</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2457&amp;key=Hc27qnWTMZOD4IP8WkNGwQ%3d%3d&amp;post=7421</link><pubDate>Tue, 30 Jan 2007 00:18:36 GMT</pubDate><description>&lt;P&gt;Is this possible?&amp;nbsp; I keep getting an exception:&lt;/P&gt;&lt;PRE class=message&gt;System.Exception: Could not find table alias for property 'orderStatus' in entity 'Design'.&lt;/PRE&gt;&lt;PRE class=message&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;lookup&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;member&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;orderStatus&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;field&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;status&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;table&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;orders&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;foreignKey&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;order_id&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;lookupKey&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;order_id&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; where = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"isnull(design.orderStatus)";&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Am I missing an attribute somwhere?&lt;/P&gt;</description></item><item><title>oPath engine that supports the EXISITS keyword</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2448&amp;key=djfPizGOTbjypwOhE%2fB6FA%3d%3d&amp;post=7408</link><pubDate>Fri, 12 Jan 2007 01:09:45 GMT</pubDate><description>&lt;P&gt;In the previous thread Jeff mentioned that he had a version of the oPath engine that supported Exists and described its use for checking if a child relation exists or not, can we have access to this buid?&lt;/P&gt;
&lt;P&gt;Thanks &lt;/P&gt;
&lt;P&gt;Floyd&lt;/P&gt;</description></item><item><title>How to determine if child records exist</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2423&amp;key=kR%2bMEY5GkFYRrMxkks9EIQ%3d%3d&amp;post=7404</link><pubDate>Wed, 10 Jan 2007 18:12:36 GMT</pubDate><description>&lt;P&gt;Jeff, can i get a copy of this opath engine with the exists support?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Floyd Price&lt;/P&gt;
&lt;P&gt;&lt;A href="mailto:f.price@componentworkshop.com"&gt;f.price@componentworkshop.com&lt;/A&gt;&lt;/P&gt;</description></item><item><title>How to determine if child records exist</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2423&amp;key=kR%2bMEY5GkFYRrMxkks9EIQ%3d%3d&amp;post=7389</link><pubDate>Fri, 05 Jan 2007 07:16:03 GMT</pubDate><description>&lt;P&gt;Hi Bill,&lt;/P&gt;
&lt;P&gt;You can use the EXISTS keyword... but support for it has not made it into a release version of WORM yet.&amp;nbsp; I have a version of 4.2.2.1 with an updated OPath Engine which supports EXISTS and IIF.&amp;nbsp; If you are interested, just send me your email address and I can send it to you.&lt;/P&gt;
&lt;P&gt;The current requirement for using EXISTS is that it must start the expression with a relationship traversal and have some sort of test within that.&lt;/P&gt;
&lt;P&gt;For example:&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;OPathQuery&amp;lt;Customer&amp;gt;("EXISTS(Orders[Freight &amp;gt; 100])");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;where Orders is the traversal giving the exists context, and Freight &amp;gt; 100 is the test in that context.&lt;/P&gt;
&lt;P&gt;In you case, the expression might look something like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;OPathQuery&amp;lt;Parent&amp;gt;("EXISTS(Children(1 = 1)")&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The "1 = 1" part is something of a hack until I can figure out how to get around it.&amp;nbsp; You should be able to have a relationship name in the exists without a test (e.g., EXISTS(Children)) but I haven't had the mental energy yet to figure out what needs to be modified in the parser.&lt;/P&gt;
&lt;P&gt;Sorry for the late reply; sort of dropped everything during the holiday season.&lt;/P&gt;
&lt;P&gt;- Jeff Lanning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>How to determine if child records exist</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2423&amp;key=kR%2bMEY5GkFYRrMxkks9EIQ%3d%3d&amp;post=7349</link><pubDate>Thu, 21 Dec 2006 16:17:56 GMT</pubDate><description>&lt;P&gt;I'm fairly comfortable with SQL, but OPath is new to me.&amp;nbsp; I've looked through the OPath documentation and I've done some searching on the Web, but I haven't been able to find any examples&amp;nbsp;showing how to&amp;nbsp;construct an OPath query which retrieves only objects which have at least one child in a child collection.&lt;/P&gt;
&lt;P&gt;I'd like to&amp;nbsp;retrieve records in table 'Parent' which have a record in table&amp;nbsp;'Child' where Parent has a one-to-many (foreign key) relationship with Child.&lt;/P&gt;
&lt;P&gt;The SQL I'm trying to generate would look something like:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;SELECT&amp;nbsp;parent_id FROM Parent WHERE EXISTS (SELECT * FROM Child WHERE Child.parent_id = Parent.parent_id)&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;OR&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SELECT DISTINCT parent_id FROM Parent P INNER JOIN Child C ON P.parent_id = C.parent_id&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;OR&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SELECT DISTINCT parent_id FROM Child&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;OR&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SELECT parent_id, COUNT(child_id)&amp;nbsp;FROM Parent P INNER JOIN Child C ON P.parent_id = C.parent_id GROUP BY parent_id HAVING Count(child_id) &amp;gt; 0&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;Does anyone&amp;nbsp;have any hints?&lt;/P&gt;
&lt;P dir=ltr&gt;Thank you,&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr&gt;Bill Daly&lt;/P&gt;
&lt;P dir=ltr&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description></item><item><title>parameterising OPath queries</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2385&amp;key=w1%2fPAuNoIh9mEg71Dj%2fQ9A%3d%3d&amp;post=7346</link><pubDate>Thu, 21 Dec 2006 16:17:45 GMT</pubDate><description>many thanks :)</description></item><item><title>opath query and paging</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2391&amp;key=sZ5Wca6HPcqcsWK6QoA5pw%3d%3d&amp;post=7345</link><pubDate>Thu, 21 Dec 2006 16:17:43 GMT</pubDate><description>&lt;P&gt;Hi jeff&lt;/P&gt;
&lt;P&gt;thanks for your reply. very informative :)&lt;/P&gt;</description></item><item><title>parameterising OPath queries</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2385&amp;key=w1%2fPAuNoIh9mEg71Dj%2fQ9A%3d%3d&amp;post=7262</link><pubDate>Wed, 08 Nov 2006 10:38:10 GMT</pubDate><description>&lt;P&gt;OPathQuery query = new OPathQuery(typeof(SettingValue), "FormatList.FormatID == ? &amp;amp;&amp;amp; SettingID == ?");&lt;/P&gt;
&lt;P&gt;MyObjectSpaceObject.GetObjectSet(typeof(SettingValue), query, formatId, settingId);&lt;/P&gt;
&lt;P&gt;or for .NET 2:&lt;/P&gt;
&lt;P&gt;OPathQuery query = new OPathQuery&amp;lt;SettingValue&amp;gt;("FormatList.FormatID == ? &amp;amp;&amp;amp; SettingID == ?");&lt;/P&gt;
&lt;P&gt;MyObjectSpaceObject.GetObjectSet&amp;lt;SettingValue&amp;gt;(query, formatId, settingId);&lt;/P&gt;</description></item><item><title>opath query and paging</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2391&amp;key=sZ5Wca6HPcqcsWK6QoA5pw%3d%3d&amp;post=7267</link><pubDate>Thu, 02 Nov 2006 10:08:12 GMT</pubDate><description>&lt;P&gt;Paging has become my personal nemesis.&amp;nbsp; I've poured god knows how many hours into solving the problem but I'm pretty much back at the drawing board at this point and haven't worked on it for months.&lt;/P&gt;
&lt;P&gt;This problem is made particularly bad due to a number of things.&amp;nbsp; Supporting Access is really hard, almost impossible, so I'll likely be putting a NotSupportedException in that code path.&amp;nbsp; Support for SQL Server 2000 and 2005 almost has to be hard coded into the engine because MS doesn't like the LIMIT keyword for some reason.&amp;nbsp; In addition, I've found it hard to provide any sort of flexibility via the CustomerProvider configuration settings.&amp;nbsp; SQL 2000 support is really the kicker though.&amp;nbsp; All sorts of nasty problems surface as soon as you have joins, table aliases, and parameters in the core select statement.&amp;nbsp; Overcoming this will require either a compete overhaul of the OPath engine or some really smart regex patterns, or the like, to chop up the results from the compiler, clone the fragments into the right pattern, then re-alias all the tables.&amp;nbsp; When my day job settles down a bit I'll try to hack some post-processor thing together that could be used to build paging queries.&amp;nbsp; If anyone has messed around with approach at all, I'd love to see it.&lt;/P&gt;
&lt;P&gt;Regarding specifying the paging values, I'm still flexible here but I don't think I want to take the page size, page number route.&amp;nbsp; The last version of WinFS that had an OPath engine in it used the keywords "Skip" and "Take".&amp;nbsp; If you combine that with the "Fluent Interface" [Fowler] I'm working on you would get something like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;List&amp;lt;Address&amp;gt; addresses = OPathQuery&amp;lt;Address&amp;gt;()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where("City = ? AND State = ?")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Sort("ZipCode ASC, StreetLine1 ASC")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Skip(40).Take(10)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Parameters(someCity, someState)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.GetList(engine);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Or a number of variations on that theme:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;List&amp;lt;Address&amp;gt; addresses = OPathQuery&amp;lt;Address&amp;gt;()&lt;BR&gt;&amp;nbsp;.Where("City = ? AND State = ?")&lt;BR&gt;&amp;nbsp;.Sort("ZipCode ASC, StreetLine1 ASC")&lt;BR&gt;&amp;nbsp;.Skip(40).Take(10)&lt;BR&gt;&amp;nbsp;.GetList(engine, &lt;STRONG&gt;someCity, someState&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;List&amp;lt;Address&amp;gt; addresses = OPathQuery&amp;lt;Address&amp;gt;()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where("City = ? AND State = ?", &lt;STRONG&gt;someCity, someSate&lt;/STRONG&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Sort("ZipCode ASC, StreetLine1 ASC")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Skip(40).Take(10)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.GetList(engine);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Perhaps even:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;List&amp;lt;Address&amp;gt; addresses = &lt;STRONG&gt;engine&lt;/STRONG&gt;.GetList&amp;lt;Address&amp;gt;()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where("City = ? AND State = ?", someCity, someSate)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Sort("ZipCode ASC, StreetLine1 ASC")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Skip(40).Take(10);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;- Jeff Lanning&lt;/P&gt;</description></item><item><title>parameterising OPath queries</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2385&amp;key=w1%2fPAuNoIh9mEg71Dj%2fQ9A%3d%3d&amp;post=7266</link><pubDate>Thu, 02 Nov 2006 09:33:39 GMT</pubDate><description>&lt;P&gt;Just replace each variable in your query with a question mark, like so:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;OPathQuery query = new OPathQuery(typeof(SettingValue), "FormatList.FormatID =&amp;nbsp;? &amp;amp;&amp;amp; SettingID = ?);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Then pass the values when you execute the query:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;ObjectSet&amp;nbsp;results = WormEngine.GetObjectSet(formatID, settingID);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;- Jeff Lanning&lt;/P&gt;</description></item><item><title>opath query and paging</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2391&amp;key=sZ5Wca6HPcqcsWK6QoA5pw%3d%3d&amp;post=7254</link><pubDate>Tue, 31 Oct 2006 14:25:47 GMT</pubDate><description>&lt;P&gt;Hi Jeff&lt;/P&gt;
&lt;P&gt;Last time I looked I saw that paging was not yet implemented for opath queries. I know you're working on it. Aren't you a star! I'm sitting with baited breath patiently waiting for paging support&lt;/P&gt;
&lt;P&gt;My question is hypothetical. When paging is released will it be based on an object design whereby the opath query object has properties like startIndex and maxRows?&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;P&gt;andrea&lt;/P&gt;</description></item><item><title>parameterising OPath queries</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2385&amp;key=w1%2fPAuNoIh9mEg71Dj%2fQ9A%3d%3d&amp;post=7245</link><pubDate>Tue, 31 Oct 2006 14:25:37 GMT</pubDate><description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I have an opath query as show below. How would i parameterise it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OPath query query = new OPathQuery(typeof(SettingValue), " FormatList.FormatID = '" + formatID + "' &amp;amp;&amp;amp; SettingID='" + settingID + "'");&lt;/P&gt;
&lt;P&gt;many thanks&lt;/P&gt;
&lt;P&gt;anndrea&lt;/P&gt;</description></item><item><title>OPath query in a self-referencing table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2341&amp;key=TyAIqdhwErY%2bfIARjycQWw%3d%3d&amp;post=7213</link><pubDate>Tue, 03 Oct 2006 02:19:57 GMT</pubDate><description>&lt;font size="2"&gt;&lt;font face="Arial"&gt;Hi Jeff,&lt;br&gt;&lt;br&gt;I'm so glad to get a response on this :o) It's a fairly important part of this app so I fretted about it a bit. I have not made further attempts to do it with OPath - instead I have kludged it using raw SQL to project just Dog IDs and iterating through the list to get the Dog objects. Nasty!! It's definitely not ideal since one of my original aim for the app is to be as DMBS-neutral as possible.&lt;br&gt;&lt;br&gt;I will try your OPath query but at the moment I've left OPath alone - especially since I couldn't get it working for a fairly simple query that I posted on another thread.&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;Dany.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>A simple OPath question</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2351&amp;key=J687CdhDKkLmMOVHOqkyXQ%3d%3d&amp;post=7212</link><pubDate>Tue, 03 Oct 2006 02:10:15 GMT</pubDate><description>&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Sorry, forgot to mention, the mapping and classes were generated with Paul Welter's latest template. I have never ventured to manual mapping generation yet...&lt;br&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>A simple OPath question</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2351&amp;key=J687CdhDKkLmMOVHOqkyXQ%3d%3d&amp;post=7211</link><pubDate>Tue, 03 Oct 2006 02:08:16 GMT</pubDate><description>&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Hi Jeff,&lt;br&gt;&lt;br&gt;Yup, I'm still having problems. It's more like the former of the two you mentioned. The collection "pups" always has zero count.&lt;br&gt;&lt;br&gt;I'm using SharpDevelop and fairly new at it so not sure how all the features work. Not sure if I can debug and see what the SQL query from that OPath looks like, nor can I "profile" the DB calls like MSSQL.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;D.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>OPath query in a self-referencing table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2341&amp;key=TyAIqdhwErY%2bfIARjycQWw%3d%3d&amp;post=7206</link><pubDate>Mon, 02 Oct 2006 07:24:22 GMT</pubDate><description>&lt;P&gt;Hi Dany,&lt;/P&gt;
&lt;P&gt;Sorry for the delayed reply.&amp;nbsp; Have you figured this problem out yet?&amp;nbsp; I’ve been kicking this around a bit but nothing easy is coming to mind... and nothing nearly as efficient as your hand built sql query).&lt;/P&gt;
&lt;P&gt;Breaking down your joins, I get the following:&lt;/P&gt;
&lt;P&gt;M = Mother&lt;BR&gt;GP = Mother.Mother or Mother.Father&lt;BR&gt;GGF = Mother.Mother.Father or Mother.Father.Father &lt;/P&gt;
&lt;P&gt;From this, my best guess is that the following query would be close:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;OPathQuery&amp;lt;Dog&amp;gt;("Mother[(Mother.Father.ID = Father.ID) OR (Father.Father.ID = Father.ID)]")&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;However, I’m pretty sure this is unsupported syntax.&amp;nbsp; It might just work but I have a feeling you’ll get an error about traversals on both sides of the expression.&amp;nbsp; If so, that can be solved using the parent traversal operator:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#008000&gt;OPathQuery&amp;lt;Dog&amp;gt;("Mother[Mother.Father[ID = ^.^.^.Father.ID] OR Father.Father[ID = ^.^.^.Father.ID]]")&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The generated query is going to look really nasty but I have your dataset is pretty small so performance is not terribly important.&lt;/P&gt;
&lt;P&gt;Let me know if this works or gets you on the right track.&lt;/P&gt;
&lt;P&gt;- Jeff Lanning&lt;BR&gt;&lt;/P&gt;</description></item><item><title>Paging / Sorting / Dynamic Query!!!</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2344&amp;key=twWrfI4VA1iJlOsL3fALFA%3d%3d&amp;post=7205</link><pubDate>Mon, 02 Oct 2006 06:49:53 GMT</pubDate><description>&lt;P&gt;There is no simple answer to this at the moment.&amp;nbsp; The best I can recommend is to either manually build the query using ObjectQuery and QueryHelper or get the generated sql by compiling the OPathQuery and doing some string parsing to build a paging version.&lt;/P&gt;
&lt;P&gt;- Jeff Lanning&lt;/P&gt;</description></item><item><title>For gods' sake!!</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2345&amp;key=p73NrHOvg2heei9SVGjjhw%3d%3d&amp;post=7204</link><pubDate>Mon, 02 Oct 2006 06:45:35 GMT</pubDate><description>&lt;P&gt;Sorting can be done by specifying the sort expression when building the query.&amp;nbsp; Paging is not currently&amp;nbsp;supported.&amp;nbsp; This is something I have spent a lot of time working on but have not gotten the code to a point where it is ready for release.&amp;nbsp; Perhaps things will calm down a bit at work over fall/winter and I can invest more time into tackling this issue.&amp;nbsp; Until then your best option is to either use&amp;nbsp;an ObjectQuery with the QueryHelper to build the paging query manually or get the generated sql by compiling the OPathQuery and do some string parsing to build a paging version.&lt;/P&gt;
&lt;P&gt;- Jeff Lanning&lt;/P&gt;</description></item><item><title>A simple OPath question</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2351&amp;key=J687CdhDKkLmMOVHOqkyXQ%3d%3d&amp;post=7203</link><pubDate>Mon, 02 Oct 2006 06:39:06 GMT</pubDate><description>&lt;P&gt;Hi Dany,&lt;/P&gt;
&lt;P&gt;Are you still having trouble?&amp;nbsp; If so, is the problem with the OPath query not returning the correct results or the objects returned from the query not having the correct data in the collections?&amp;nbsp; If it's the latter as I suspect, than there is likely something up with the mapping file/entity class.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR&gt;Jeff Lanning&lt;BR&gt;&lt;/P&gt;</description></item><item><title>A simple OPath question</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2351&amp;key=J687CdhDKkLmMOVHOqkyXQ%3d%3d&amp;post=7190</link><pubDate>Wed, 27 Sep 2006 11:12:55 GMT</pubDate><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Hi everyone,&lt;BR&gt;&lt;BR&gt;I have used Paul's ORM for a few days now and really enjoying it. Things are beginning to work quite nicely! Today was the first time I wanted to use an OPathQuery.&lt;BR&gt;&lt;BR&gt;Here's what my SQL query looks like:&lt;BR&gt;&lt;BR&gt;select p.petname&lt;BR&gt;from dog p&lt;BR&gt;inner join dog s on p.sire = s.id&lt;BR&gt;where s.petname = 'turi'&lt;BR&gt;&lt;BR&gt;The Dog object was mapped by Paul Welter's template to have a SireDogObject&lt;BR&gt;&lt;BR&gt;Here's my OPath query and the code:&lt;BR&gt;&lt;BR&gt;OPathQuery&amp;lt;Dog&amp;gt; query = new OPathQuery&amp;lt;Dog&amp;gt;("SireDogObject.PetName == ?");&lt;BR&gt;Collection&amp;lt;Dog&amp;gt; pups = DataManager.ObjectSpace.GetCollection&amp;lt;Dog(query,"Turi");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;Well, the SQL query returns two rows but the pups collection contains 0 objects! It feels like I have a fundamentally wrong understanding of how OPath works. Can someone please help put me on the right track?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;Many thanks,&lt;BR&gt;Dany.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description></item><item><title>For gods' sake!!</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2345&amp;key=p73NrHOvg2heei9SVGjjhw%3d%3d&amp;post=7179</link><pubDate>Tue, 26 Sep 2006 09:08:56 GMT</pubDate><description>I need to do paging and sorting given an OPath query? How?</description></item><item><title>Paging / Sorting / Dynamic Query!!!</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2344&amp;key=twWrfI4VA1iJlOsL3fALFA%3d%3d&amp;post=7177</link><pubDate>Tue, 26 Sep 2006 09:08:53 GMT</pubDate><description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have an OPathQuery and i want to call GetObjectSet. Also i have a object[] of query parameters. What should i do?&lt;/P&gt;
&lt;P&gt;I tried converting OPathQuery to ObjectQuery but i could not. I tried using CompiledQuery but it doesnt support paging&amp;nbsp; and sorting?&lt;/P&gt;
&lt;P&gt;Please advice.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;-Shadi Mari&lt;/P&gt;</description></item><item><title>OPath query in a self-referencing table</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2341&amp;key=TyAIqdhwErY%2bfIARjycQWw%3d%3d&amp;post=7174</link><pubDate>Tue, 26 Sep 2006 09:08:39 GMT</pubDate><description>&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Hi folks,&lt;br&gt;&lt;br&gt;I am new to the whole ORM usage, let alone the OPath language. The helper tool has interpreted the mapping and object correctly. Here's the scenario:&lt;br&gt;&lt;br&gt;I have a Dog table with columns: Id, Name, Mother, Father, where Mother and Father are self-referencing foreign keys.&lt;br&gt;&lt;br&gt;If you're familiar with animal breeding then I'm after Dogs resulting from line breeding, i.e. Grandfather/Granddaughter mating. No bluegrass music jokes please...these are Dogs!&lt;br&gt;&lt;br&gt;In SQL my query looks like:&lt;br&gt;&lt;br&gt;Select x.*&lt;br&gt;From dog x&lt;br&gt;Join dog m on m.id = x.mother&lt;br&gt;Join dog gp on gp.id = m.mother or gp.id = m.father&lt;br&gt;Join dog ggf on ggf.id = gp.father and ggf.id = x.father&lt;br&gt;&lt;br&gt;How on earth would I interpret that into OPath? Any assistance would be immensely appreciated.&lt;br&gt;&lt;br&gt;Many thanks,&lt;br&gt;Dany.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>TOP + LEFT JOIN + ORDER</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2316&amp;key=syeSlgeRSUUhL39najeMCA%3d%3d&amp;post=7163</link><pubDate>Tue, 19 Sep 2006 17:15:59 GMT</pubDate><description>Have you looked at the lookup feature?&amp;nbsp; The Example app has an example, and it is documented in the Wiki with all the other mapping docs.&amp;nbsp; Without knowing a lot more about your particular case I can't give you the exact details, but it sounds like this would be what you want.&amp;nbsp; If that isn't it for some reason, then I typically recommend creating a view -- not totally database independent, but its almost universal.&lt;br&gt;&lt;br&gt;Thanks, Paul Wilson&lt;br&gt;</description></item><item><title>TOP + LEFT JOIN + ORDER</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2316&amp;key=syeSlgeRSUUhL39najeMCA%3d%3d&amp;post=7161</link><pubDate>Tue, 19 Sep 2006 15:42:15 GMT</pubDate><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Hi Paul,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Thanks for the reply&amp;nbsp;and for your professional opinion ;p&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;By the why… my question remains… using the same approach (QueryHelper/ObjectQuery to build queries)&lt;STRONG&gt;&amp;nbsp;How you do this ?&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;//SELECT TOP 1 * FROM page_Content &lt;BR&gt;//LEFT JOIN page_Attachments on page_Content.FileAttachId=page_Attachments.FileAttachId&lt;BR&gt;//WHERE &lt;/FONT&gt;&lt;A href="mailto:PageId=@PageId"&gt;&lt;FONT face=Tahoma size=2&gt;PageId=@PageId&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma size=2&gt; ORDER BY PageVersion DESC&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;The problem here is how you reproduce the LEFT JOIN using the QueryHelper/ObjectQuery approach&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>TOP + LEFT JOIN + ORDER</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2316&amp;key=syeSlgeRSUUhL39najeMCA%3d%3d&amp;post=7160</link><pubDate>Tue, 19 Sep 2006 14:56:11 GMT</pubDate><description>&lt;font color="#000000" face="Tahoma" size="2"&gt;Its a minor difference to use the QueryHelper:&lt;br&gt;&lt;br&gt;int PageId = 1;&lt;br&gt;string where = QueryHelper.GetExpression("PageContent.PageId", PageId);&lt;br&gt;ObjectQuery&amp;lt;PageContent&amp;gt; query = new ObjectQuery&amp;lt;PageContent&amp;gt;(where, string.Empty, 1, 1);&lt;br&gt;&lt;br&gt;What's the difference?&amp;nbsp; It will take care of the things like quotes for strings, including "cleaning" of strings, and things like formatting of dates for your specific database.&amp;nbsp; It also means that you can think in terms of your Class.Property naming, so somewhat OO, without having to worry about table and field names which is another good abstraction.&lt;br&gt;&lt;br&gt;Again all I can say is this is my personal preference, but I don't want to imply OPath is not just as "good" -- its simply a case here with paging where OPath doesn't yet give you what you need.&lt;br&gt;&lt;br&gt;Thanks, Paul Wilson&lt;br&gt; &lt;/font&gt;</description></item><item><title>TOP + LEFT JOIN + ORDER</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2316&amp;key=syeSlgeRSUUhL39najeMCA%3d%3d&amp;post=7158</link><pubDate>Tue, 19 Sep 2006 10:03:48 GMT</pubDate><description>&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;Hi Paul,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;&lt;FONT color=#006400&gt;&lt;EM&gt;&amp;gt;&amp;gt; I hate to be firm, but I've also given you the correct syntax for doing this in your other thread several weeks ago&lt;/EM&gt;&lt;/FONT&gt;&lt;BR&gt;No problem! Note that I am not asking the same question. I only said that I am trying to avoid that "build a SQL query manually" and give the example, why :p&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt;&lt;EM&gt;&amp;gt;&amp;gt;You use the QueryHelper with the ObjectQuery so that you won't be manually building expressions and worrying about table and field names, so it basically lets you think in sql syntax while still helping you with the actual sql. &lt;BR&gt;&amp;gt;&amp;gt;...Anyhow, to make a long story short, you do have what you need to create this query...&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;I did not say that I don’t have what I need to create this query... the problem is HOW to create it !&lt;BR&gt;Please provide examples !!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;If I want this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt;//SELECT TOP 1 * FROM page_Content &lt;BR&gt;//WHERE &lt;/FONT&gt;&lt;A href="mailto:PageId=@PageId"&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt;PageId=@PageId&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;I do this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;int PageId = 1;&lt;BR&gt;string where = "PageId=" + PageId;&lt;BR&gt;ObjectQuery&amp;lt;PageContent&amp;gt; query = new ObjectQuery&amp;lt;PageContent&amp;gt;(where, string.Empty, 1, 1);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;Can you put the sample using the QueryHelper/ObjectQuery to build this query ? :&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt;//SELECT TOP 1 * FROM page_Content &lt;BR&gt;//LEFT JOIN page_Attachments on page_Content.FileAttachId=page_Attachments.FileAttachId&lt;BR&gt;//WHERE &lt;/FONT&gt;&lt;A href="mailto:PageId=@PageId"&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt;PageId=@PageId&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma color=#006400 size=2&gt; ORDER BY PageVersion DESC&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;That is my question!! How to do it!!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=2&gt;Sorry and please understand that I new in this kind of stuff and I need some "basic" help.!&lt;BR&gt;&lt;STRONG&gt;Thanks again :p&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description></item><item><title>TOP + LEFT JOIN + ORDER</title><link>http://wilsonormapper.com/Forums/Default.aspx?part=74&amp;action=thread&amp;id=2316&amp;key=syeSlgeRSUUhL39najeMCA%3d%3d&amp;post=7154</link><pubDate>Mon, 18 Sep 2006 14:12:18 GMT</pubDate><description>The ObjectQuery allows you to specify page size and count in a way that the ORMapper will build the sql for the correct database.&amp;nbsp; In this case case you want the first page with the size also being one.&amp;nbsp; I hate to be firm, but I've also given you the correct syntax for doing this in your other thread several weeks ago, so I'm assuming I do not need to do so again.&lt;br&gt;&lt;br&gt;Note that using the ObjectQuery is not somehow "worse" than using OPath -- it simply expects you to think using sql syntax instead of object syntax.&amp;nbsp; Some people prefer one technique over the other, so both are included, but one is not "worse" or "better" than the other.&amp;nbsp; You use the QueryHelper with the ObjectQuery so that you won't be manually building expressions and worrying about table and field names, so it basically lets you think in sql syntax while still helping you with the actual sql.&amp;nbsp; It is true that Jeff has supplied a lot more operators in the OPath syntax, but they don't apply to most queries, and in most cases they are the types of things that are pretty standard in most databases anyhow, so I still think its almost always a case of your preference being sql or object syntax.&amp;nbsp; I'm an OO developer, but I'm also a database developer, and I like to think of my queries in terms of sql because of that -- no matter how much O/R Mappers bridge the gap its still true that you are working with a database in the end, and I already know sql so I don't see the point in learning another language (like OPath).&amp;nbsp; That's also the beauty that MS is working on for Linq -- you get to work with sql-like syntax instead of learning a new language, although certainly the tool support will make it better than what I can offer.&lt;br&gt;&lt;br&gt;Anyhow, to make a long story short, you do have what you need to create this query, and even though it may not be possible with OPath, all that means is that you have to think in terms of sql -- it does not mean that you actually have to create all the sql yourself or get stuck without support for multiple databases.&lt;br&gt;&lt;br&gt;Thanks, Paul Wilson&lt;br&gt;</description></item></channel></rss>