<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET Dynamic Data</title><link>http://forums.asp.net/1145.aspx</link><description>Discussions regarding the new scaffolding framework in ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Entity Sql - Count function</title><link>http://forums.asp.net/thread/3519347.aspx</link><pubDate>Wed, 18 Nov 2009 09:34:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3519347</guid><dc:creator>gameover88</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3519347.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3519347</wfw:commentRss><description>&lt;p&gt;well it&amp;#39;s a little bit late but thanks a lot for your help :)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Entity Sql - Count function</title><link>http://forums.asp.net/thread/3273560.aspx</link><pubDate>Fri, 03 Jul 2009 13:10:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273560</guid><dc:creator>andreadottor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273560.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3273560</wfw:commentRss><description>&lt;p&gt;Is normal the type is a generic list, because you execute a select that can return many values.&lt;br /&gt;&lt;br /&gt;In a my application (that I have a similar situation) I have create a method that check that the list is not empty and return a value (that is the first element).&lt;br /&gt;&lt;br /&gt;In you case, the code can be this:&lt;/p&gt;
&lt;p&gt;protected int GetCount(IList&amp;lt;int&amp;gt; count)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (count == null || count.Count &amp;lt; 1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return count[0];&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;or check in debug the correct type. &lt;/p&gt;</description></item><item><title>Re: Entity Sql - Count function</title><link>http://forums.asp.net/thread/3273545.aspx</link><pubDate>Fri, 03 Jul 2009 12:55:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273545</guid><dc:creator>gameover88</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273545.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3273545</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;andreadottor:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;
&lt;p&gt;I don&amp;#39;t have try, but in your query missed &amp;quot;as c&amp;quot; near Comments, and you must indicate the name of the class of your ObjectContext&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i can&amp;#39;t believe how i forgot this.) thanks. now i&amp;#39;m writing this statement:&lt;/p&gt;
&lt;p&gt;SELECT m.MediaTitle, (Select COUNT(c.MediaID) FROM MediaPortalEntities.Comments AS c WHERE c.MediaID = m.MediaID) AS TotalComments FROM MediaPortalEntities.Medias AS m&lt;/p&gt;
&lt;p&gt;But during the run time this is what it shows in the datalist: &lt;/p&gt;
&lt;p&gt;
&lt;table style="BORDER-COLLAPSE:collapse;" id="DataList2" cellspacing="0"&gt;

&lt;tr&gt;
&lt;td&gt;MediaTitle: &lt;span id="DataList2_ctl00_MediaTitleLabel"&gt;Fight Club&lt;/span&gt; &lt;br /&gt;TotalComments: &lt;span id="DataList2_ctl00_TotalCommentsLabel"&gt;System.Collections.Generic.List`1[System.Data.Common.DbDataRecord]&lt;/span&gt; &lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;MediaTitle: &lt;span id="DataList2_ctl01_MediaTitleLabel"&gt;The Dark Knight&lt;/span&gt; &lt;br /&gt;TotalComments: &lt;span id="DataList2_ctl01_TotalCommentsLabel"&gt;System.Collections.Generic.List`1[System.Data.Common.DbDataRecord]&lt;/span&gt; &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;..&lt;/p&gt;
&lt;p&gt;still can&amp;#39;t get the count numbers :S&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description></item><item><title>Re: Entity Sql - Count function</title><link>http://forums.asp.net/thread/3273479.aspx</link><pubDate>Fri, 03 Jul 2009 12:17:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273479</guid><dc:creator>andreadottor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273479.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3273479</wfw:commentRss><description>&lt;p&gt;I don&amp;#39;t have try, but in your query missed &amp;quot;as c&amp;quot; near Comments, and you must indicate the name of the class of your ObjectContext&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;SELECT &lt;br /&gt;&amp;nbsp; m.MediaTitle, &lt;br /&gt;&amp;nbsp; m. SuggestedBy, &lt;br /&gt;&amp;nbsp; m.Summary, &lt;br /&gt;&amp;nbsp; (Select COUNT(c.MediaID) FROM &lt;strong&gt;YourObjectContext&lt;/strong&gt;.Comments &lt;strong&gt;AS c&lt;/strong&gt; WHERE c.MediaID = m.MediaID) AS TotalComments &lt;br /&gt;FROM &lt;strong&gt;YourObjectContext&lt;/strong&gt;.Medias AS m&lt;/p&gt;</description></item><item><title>Entity Sql - Count function</title><link>http://forums.asp.net/thread/3273269.aspx</link><pubDate>Fri, 03 Jul 2009 10:17:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273269</guid><dc:creator>gameover88</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273269.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3273269</wfw:commentRss><description>&lt;p&gt;Hi. i&amp;#39;m trying to write an e-sql statement that retrieves all records in a table called &amp;#39;Medias&amp;#39; and also,&amp;nbsp;number of the comments those belong to each Media, by MediaID&amp;nbsp;(in the Comments table). i&amp;#39;ve tried several statements like this but i always get error:&lt;/p&gt;
&lt;p&gt;SELECT m.MediaTitle, m. SuggestedBy, m.Summary, (Select COUNT(c.MediaID) FROM Comments WHERE c.MediaID = m.MediaID) AS TotalComments FROM Medias AS m&lt;/p&gt;
&lt;p&gt;i know this may sound easy but i&amp;#39;m in trouble with this :(. i would appreciate if you could help. thanks a lot.&lt;/p&gt;</description></item></channel></rss>