<?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 : Passing an EntityList?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Passing an EntityList?</description>
  <pubDate>Wed, 10 Jun 2026 20:47:33 -700</pubDate>
  <lastBuildDate>Tue, 09 Sep 2008 21:17:52 -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=932</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>Passing an EntityList? : In order to use IEnumerable without...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3374#3374</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=34" rel="nofollow">jeffdoolittle</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 09-Sep-2008 at 9:17pm<br /><br />In order to use IEnumerable without a type parameter, you need a using statement that references System.Collections:<br><br>using System.Collections;<br><br>To get a reference to the extension method .Cast&lt;T&gt;(), you need a using statement like this:<br><br>using System.Linq;<br><br><br><br>]]>
   </description>
   <pubDate>Tue, 09 Sep 2008 21:17:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3374#3374</guid>
  </item> 
  <item>
   <title>Passing an EntityList? :  Thanks for your reply, Jeff....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3373#3373</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=92" rel="nofollow">HFloyd</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 09-Sep-2008 at 8:43pm<br /><br />Thanks for your reply, Jeff. <br><br>Well, I tried leaving the T out:<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp; private IEnumerable mListMainEntity;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected IEnumerable MainEntityList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return mListMainEntity; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { mListMainEntity = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br></pre></td></tr></table><br><br>but get a Build error:<br><font color="#ff0000">Using the generic type 'System.Collections.Generic.IEnumerable&lt;T&gt;' requires '1' type arguments&nbsp;&nbsp; </font><br><br>I was intrigued by your second suggestion, since all I need is the Count, which is a property of Entity,&nbsp; but also cannot get it formatted correctly.<br>This is what I tried:<br><table width="99%"><tr><td><pre class="BBcode"><br>base.MainEntityList = mListMainEntity.Cast&lt;Entity&gt;();<br></pre></td></tr></table><br>(The mListMainEntity already exists, I just want to pass it to the base)<br><table width="99%"><tr><td><pre class="BBcode"><br>private EntityList&lt;HouseholdBusiness&gt; mListMainEntity= new EntityList&lt;HouseholdBusiness&gt;();<br></pre></td></tr></table><br><br>The build error is: <br><font color="#ff0000">'IdeaBlade.Persistence.EntityList&lt;HS.Admin.Model.HouseholdBusiness&gt;' does not contain a definition for 'Cast' and the best extension method overload 'System.Data.EnumerableRowCollectionExtensions.Cast&lt;TResult&gt;(System.Data.EnumerableRowCollection)' has some invalid arguments </font><br><br>I tried other combinations, but none were acceptable to the compiler:<br><table width="99%"><tr><td><pre class="BBcode"><br>base.MainEntityList = mListMainEntity().Cast&lt;Entity&gt;(); <font color="#ff0000">&lt;--Doesn't compile</font><br></pre></td></tr></table><br><br>I was able to compile with this:<br><table width="99%"><tr><td><pre class="BBcode"><br>base.MainEntityList = (IEnumerable&lt;Entity&gt;)mListMainEntity;<br></pre></td></tr></table><br><br>but then got a runtime exception:<br><font color="#ff0000">System.InvalidCastException was unhandled by user code<br>&nbsp; Message="Unable to cast object of type 'IdeaBlade.Persistence.EntityList`1&#091;HS.Admin.Model.HouseholdBusiness&#093;' to type 'System.Collections.Generic.IEnumerable`1&#091;IdeaBlade.Persistence.Entity&#093;'."</font><br><br>I'm not sure how to proceed.<br><br>Heather<br><br><span style="font-size:10px"><br /><br />Edited by HFloyd - 09-Sep-2008 at 8:44pm</span>]]>
   </description>
   <pubDate>Tue, 09 Sep 2008 20:43:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3373#3373</guid>
  </item> 
  <item>
   <title>Passing an EntityList? : You can&amp;#039;t use IEnumerable&amp;lt;Entity&amp;gt;,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3369#3369</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=34" rel="nofollow">jeffdoolittle</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 09-Sep-2008 at 8:51am<br /><br />You can't use IEnumerable&lt;Entity&gt;, you have to just use IEnumerable.&nbsp; Generics collections don't know how to auto-cast their members to a base type, so you can't do this:<br><br>IEnumerable&lt;Entity&gt; collection = new EntityList&lt;HouseholdBusiness&gt;();<br><br>because "T" is not the same for both collections.<br><br>You can either just just IEnumerable without a generic type constraint, or you could try this:<br><br>IEnumerable&lt;Entity&gt; collection = new EntityList&lt;HouseholdBusiness&gt;().Cast&lt;Entity&gt;();<br><br>which uses a Linq extension method to do the list cast for you.<br>]]>
   </description>
   <pubDate>Tue, 09 Sep 2008 08:51:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3369#3369</guid>
  </item> 
  <item>
   <title>Passing an EntityList? : Hi Jeff, Thanks for your idea,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3368#3368</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=92" rel="nofollow">HFloyd</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 09-Sep-2008 at 8:36am<br /><br />Hi Jeff, <br><br>Thanks for your idea, but I'm afraid I'm not sure how to implement it.<br><br>I put this into BASE:<br><table width="99%"><tr><td><pre class="BBcode"><br>private IEnumerable&lt;Entity&gt; mListMainEntity;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected IEnumerable&lt;Entity&gt; MainEntityList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return mListMainEntity; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { mListMainEntity = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></pre></td></tr></table><br><br>But am having trouble assigning it from the Derived form:<br><table width="99%"><tr><td><pre class="BBcode"><br>private EntityList&lt;HouseholdBusiness&gt; mListMainEntity = new EntityList&lt;HouseholdBusiness&gt;();<br><br>base.MainEntityList = mListMainEntity;<br></pre></td></tr></table><br><br>The message is:<br><font color="#ff0000">Cannot implicitly convert type 'IdeaBlade.Persistence.EntityList&lt;HS.Admin.Model.HouseholdBusiness&gt;' to 'System.Collections.Generic.IEnumerable&lt;IdeaBlade.Persistence.Entity&gt;'. An explicit conversion exists (are you missing a cast?) </font><br>&nbsp;<br>Do you happen to know the cast syntax?<br><br>Thanks, <br><br>Heather<br>]]>
   </description>
   <pubDate>Tue, 09 Sep 2008 08:36:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3368#3368</guid>
  </item> 
  <item>
   <title>Passing an EntityList? : How about using IEnumerable instead...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3367#3367</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=34" rel="nofollow">jeffdoolittle</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 07-Sep-2008 at 10:00pm<br /><br />How about using IEnumerable instead of object?&nbsp; Then make sure you have a reference to System.Linq and you can use the .Count() extension method.<br><br>--Jeff<br>]]>
   </description>
   <pubDate>Sun, 07 Sep 2008 22:00:20 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3367#3367</guid>
  </item> 
  <item>
   <title>Passing an EntityList? : Hi, I am interested in using a...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3366#3366</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=92" rel="nofollow">HFloyd</a><br /><strong>Subject:</strong> 932<br /><strong>Posted:</strong> 07-Sep-2008 at 1:08pm<br /><br />Hi, <br>I am interested in using a "base" user control for building my various usercontrols for editing each entity. I would like to have some basic functionality code in the "base" to manage operations related to Data Navigation and Adding/Saving, etc. Because I need to be able to fully access the visual controls since each derived uc will look unique, I am not including those visual (form) items in my base uc, but need to reference them (for instance, to enable/disable buttons or respond to "onclicks", etc. I figured that to get around this, I would just pass my form controls from the derived uc to the base through exposed properties. This works fine for form controls, but I am also interested in dealing directly with the EntityList of the main business object being edited on the derived uc, and can't seem to figure out how to format the property in base to accept an EntityList&lt;&gt;, which could be of whatever type.<br><br>What I have thought of is to make the base property just an "object", since the dervied uc will define what the actual entity list is, but I am having a hard time accessing properties for the EntityList/object in the base uc code. When I write "mListMainEntity.Count", the compiler won't allow it, since .Count is not defined for generic objects. This is also not allowed: "mListMainEntity&#091;"Count"&#093;". <br><br>Here is some example code:<br><br>derived uc :<br><br><table width="99%"><tr><td><pre class="BBcode"><br>private void HouseholdsBusinesses_Load(object sender, EventArgs e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.InitalizePM();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.OtherIntitalizing();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ConfigureBindingSources(); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LoadData();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Initialize Base Property Values<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.mCBM = this.dataCBM;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.mListMainEntity= mListMainEntity;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.mMainBindingSource = this.bsMainEntity;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.MainEntityType&nbsp; = typeof(HouseholdBusiness);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; <br></pre></td></tr></table><br><br>base uc:<br><br><table width="99%"><tr><td><pre class="BBcode"><br>protected object mListMainEntity;<br><br>protected object MainEntityList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return mListMainEntity; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { mListMainEntity = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>private void MainEntityListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mListMainEntity == null || <b>mListMainEntity.Count == 0</b>) <font color="#ff0000">&lt;---This is the problem area</font><br>&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; SetDNRemoveFalse();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetDNCancelEditTrue();<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; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></pre></td></tr></table><br><br>Is there some syntax I am missing? Am I going about this the wrong way?<br><br>Thanks, <br><br>Heather<br>]]>
   </description>
   <pubDate>Sun, 07 Sep 2008 13:08:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=932&amp;PID=3366#3366</guid>
  </item> 
 </channel>
</rss>