<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Manually-coded Relations between models</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Manually-coded Relations between models</description>
  <pubDate>Thu, 11 Jun 2026 03:07:38 -700</pubDate>
  <lastBuildDate>Sat, 05 Jul 2008 15:52:13 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=868</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Manually-coded Relations between models : I think that you are making things...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3172#3172</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 868<br /><strong>Posted:</strong> 05-Jul-2008 at 3:52pm<br /><br />I think that you are making things hard for yourself by creating two models (especially if you have bidirectional relationships between objects in the two different models).<DIV>&nbsp;</DIV><DIV>Also I wouldn't create a user-defined column or a try to create dynamic relationship.&nbsp; Do these things&nbsp;with the Object Mapper rather than trying to do it in code.</DIV><DIV>&nbsp;</DIV><DIV>It is fine to do automatic Customer.Location entity creation when creating new Customer entity.</DIV><DIV>&nbsp;</DIV><DIV>You should get the right PersistenceOrder automatically.</DIV><DIV>&nbsp;</DIV><DIV>I don't know of anything in DevForce EF&nbsp;that would help you that is missing in DevForce Classic.&nbsp; </DIV>]]>
   </description>
   <pubDate>Sat, 05 Jul 2008 15:52:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3172#3172</guid>
  </item> 
  <item>
   <title>Manually-coded Relations between models :    Here is my second situation.There...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3169#3169</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=201" rel="nofollow">vecs</a><br /><strong>Subject:</strong> 868<br /><strong>Posted:</strong> 03-Jul-2008 at 11:04pm<br /><br />Here is my second situation.<br><br>There are two objects in two models:<br><br><u>Model1.<b>Customer</b> </u><u>entity</u><br>&nbsp; Id (PK, int)<br>&nbsp; CompanyName<br><u><br>Model2.<b>CustomerExtention</b> </u><u>entity</u><br>&nbsp; Id (PK, int)<br>&nbsp; PrferredTransport (string)<br><br>&nbsp;&nbsp;&nbsp; There is no relation between this entities on model level, but in the logic of application they have composit relation (1-1) so objects, related the same Customer should have same PK value.<br>In my situation both objects for particular customer created as independent entities in the same PersistenceManager.<br>I want to implement required relation at runtime by providing same temporary PK value for both of this objects.<br>&nbsp;&nbsp;&nbsp; If there is way to say PersistenceManager (or BOS) that this objects single temporary PK value should be replaced by the single actual PK value during save operation? <span style="font-size:10px"><br /><br />Edited by vecs - 03-Jul-2008 at 11:05pm</span>]]>
   </description>
   <pubDate>Thu, 03 Jul 2008 23:04:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3169#3169</guid>
  </item> 
  <item>
   <title>Manually-coded Relations between models :    This is a simplifyed version...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3166#3166</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=201" rel="nofollow">vecs</a><br /><strong>Subject:</strong> 868<br /><strong>Posted:</strong> 03-Jul-2008 at 6:19am<br /><br />This is a simplifyed version of the previous question.<br>Here is my first simple situation again.<br>(I am using IdeaBlade DevForce 3.6.2.2)<br><br>1. State.<br>There are two objects in two models:<br><br><u>Model1.<b>Location</b> entity</u><br>&nbsp; Id (PK, int)<br>&nbsp; City<br>&nbsp; Street<br>&nbsp; House<br><u><br>Model2.<b>Customer</b> </u><u>entity</u><br>&nbsp; Id (PK, int)<br>&nbsp; CompanyName<br>&nbsp; LocationId (FK)<br><br>Model1 and Model2 stored in different modules or projects (say M1 and M2).<br>M2 project have reference to M1 assembly.<br><br>2. Task.<br>Link Customer entity to Location entity by LocationId field in manner of composition (1-1). It should be possible to easy get value of Customer` location property and make UI binding to it.<br><br>3. My first solution.<br><br>3.1 Add new Location property to Customer entity class:<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#091;RelationProperty("Customer_Location", QueryDirection.ParentQuery)&#093;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#091;BeforeSetValue&#093;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#091;AfterSetValue&#093;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public Model.Location Location<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Model.Location result_;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (GetInterceptor&lt;Location&gt;("Location", GetLocationImpl, out result_)) return result_;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return GetLocationImpl();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (BeforeSetValue("Location", value))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!SetInterceptor&lt;Location&gt;("Location", value, SetLocationImpl))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetLocationImpl(value);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AfterSetValue("Location");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br><font color="#990000"><b>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Here is the main logic of subj.</b></font><font color="#000000"><br></font><font color="#000099"><font color="#000000">&nbsp;</font><font color="#000000">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; private Model.Location GetLocationImpl()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br></font></font><font color="#000099"><font color="#000000">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Create dynamic </font></font><font color="#000099"><font color="#000000">relation</font></font><br><font color="#000099"><font color="#000000">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EntityRelation relation = new EntityRelation(<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new EntityColumn&#091;&#093; { Model.Location.IdEntityColumn },<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new EntityColumn&#091;&#093; { Customer.LocationIdEntityColumn },<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; false,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "Customer_Location");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Model.Location entity = GetParent&lt;Location&gt;(relation, this.PersistenceManager.DefaultQueryStrategy);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (entity.IsNullEntity)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Create new Entity when it is not assigned<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; entity = PersistenceManager.CreateEntity&lt;Location&gt;();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //PersistenceManager.GenerateId(entity, Model.Location.IdEntityColumn);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; entity.AddToManager();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return entity;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</font><br></font><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; private void SetLocationImpl(Location value)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (value == null)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetNull(this.LocationIdColumn);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetColumnValue(this.LocationIdColumn, value, value.IdColumn);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OnPropertyChanged(new PropertyChangedEventArgs("Location"));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>3.2 Provide deletion of corresponding Location entity when delete Customer entity.<br>Customer class:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public override void Delete()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Location.Delete();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; base.Delete();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>3.4. Provide right PersistenceOrder so Location entity will be inserted into DB before Customer.<br>&nbsp; This may be done by filling SaveOptions/DefaultSaveOptions.PersistenceOrder for PersistenceManager.<br><br>4. Questions.<br><br>4.1. Whether my solution correct?<br>4.2. Where is the best place to implement automatic Customer.Location entity creation when creating new Customer entity (instead of creating on first call in <font color="#000099"><font color="#000000">GetLocationImpl()</font></font>)?<br>4.3. Is it necessary to implement step 3.4 or PersistenceManager will automatically determine right PersistenceOrder with help of RelationProperty attribute or something else?<br>4.4. Does new <font face="Times New Roman" size="3">DevForce EF 4.0 have any advantages regarding cross-model relations definition?<br><br></font><span style="font-size:10px"><br /><br />Edited by vecs - 03-Jul-2008 at 10:44pm</span>]]>
   </description>
   <pubDate>Thu, 03 Jul 2008 06:19:20 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3166#3166</guid>
  </item> 
  <item>
   <title>Manually-coded Relations between models :    We have a modular application...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3158#3158</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=201" rel="nofollow">vecs</a><br /><strong>Subject:</strong> 868<br /><strong>Posted:</strong> 30-Jun-2008 at 5:09am<br /><br />We have a modular application and each application module (assembly) has its own entity model (.orm file + entity classes).<br>There is one "Sys" module that contains entity classes required by other modules (other modules projects can reference to Sys).<br>During entities development within my new application module I`d like to define relations between my entities and Sys entities by not redefining Sys entities in my module with Object Mapper. Since Object Mapper doesn't allow relations between models I need to code such relations by myself (if it is possible at all).<br>For example, I need to define relation between my Customer entity declared in My module and the Address entity declared in Sys module (i.e. add Customer.Location property which is contains link to Address entity). And PersistenceManager should manage this entities properly (build right save graph e.t.c.).<br><br>In other words, is it possible to create entity relations dynamically?<br><br>P.S.<br>It seems that my question addresses the similar problem as in this topic:<br><a href="http://www.ideablade.com/forum/forum_posts.asp?TID=834" target="_blank">http://www.ideablade.com/forum/forum_posts.asp?TID=834</a><br><br><br><br><br><span style="font-size:10px"><br /><br />Edited by vecs - 02-Jul-2008 at 3:36am</span>]]>
   </description>
   <pubDate>Mon, 30 Jun 2008 05:09:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=868&amp;PID=3158#3158</guid>
  </item> 
 </channel>
</rss>