<?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 : using the Context to CreateCommand and run sql</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : using the Context to CreateCommand and run sql</description>
  <pubDate>Wed, 10 Jun 2026 19:10:35 -700</pubDate>
  <lastBuildDate>Tue, 14 Sep 2010 14:56:21 -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=2153</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>using the Context to CreateCommand and run sql : Hi orcities;It looks like it&amp;#039;s...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2153&amp;PID=8498#8498</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2153<br /><strong>Posted:</strong> 14-Sep-2010 at 2:56pm<br /><br />Hi orcities;<div><br></div><div>It looks like it's possible. Here's my test code querying the NorthwindIB database.</div><div><br></div><div><div>public void UsingEntityConnectionWithDevForce() {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;string connectionString1 =&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ConfigurationManager.ConnectionStrings&#091;"NorthwindIBEntityManager"&#093;.ConnectionString;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;string connectionString2 = "Name = NorthwindIBEntityManager";</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;using (EntityConnection connection = new EntityConnection(connectionString2)) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;connection.Open();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;EntityCommand entityCommand = connection.CreateCommand();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;entityCommand.CommandText =&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"Select emp.FirstName as First, emp.LastName as Last " +</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "FROM NorthwindIBEntityManager.Employees AS emp";</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;EntityDataReader reader = entityCommand.ExecuteReader(CommandBehavior.SequentialAccess);</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while (reader.Read()) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Output += String.Format("{0} {1} \n", reader&#091;"First"&#093;, reader&#091;"Last"&#093;);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;connection.Close();</div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;}</div></div>]]>
   </description>
   <pubDate>Tue, 14 Sep 2010 14:56:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2153&amp;PID=8498#8498</guid>
  </item> 
  <item>
   <title>using the Context to CreateCommand and run sql : Is it possible to write straight...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2153&amp;PID=8478#8478</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=136" rel="nofollow">orcities</a><br /><strong>Subject:</strong> 2153<br /><strong>Posted:</strong> 13-Sep-2010 at 2:34pm<br /><br />Is it possible to write straight sql and get results not dependent on know which type of entity is returned. <DIV></DIV><DIV></DIV>Similar to the following:<DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">using(EntityConnection connection = new EntityConnection("Name = SchoolEntities"))</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">{</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">connection.Open();</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne"></DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">EntityCommand entityCommand = connection.CreateCommand();</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">entityCommand.CommandText =</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @"Select p.ProductID as Id from SchoolEntities.Product as p";</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">EntityDataReader entityDataReader =</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">entityCommand.ExecuteReader(CommandBehavior.SequentialAccess);</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">while (entityDataReader.Read())</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">{</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; entityDataReader.FieldCount; i++)</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.Write(entityDataReader<em>.ToString() + "\t");</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine();</DIV><DIV style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">}</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.Close();</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">}</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: n&#111;ne">I don't want to have to create two Model just to perform this option that I need.</DIV></DIV>]]>
   </description>
   <pubDate>Mon, 13 Sep 2010 14:34:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2153&amp;PID=8478#8478</guid>
  </item> 
 </channel>
</rss>