﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Mladen commented on Entity Framework: If you pass a connection to the context, you are responsible for disposing it</title><description>ahhhhhh.... now i got it. If you pass any connection into it! DOH!
  
</description><link>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment5</link><guid>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment5</guid><pubDate>Sun, 26 Sep 2010 14:13:58 GMT</pubDate></item><item><title>Ayende Rahien commented on Entity Framework: If you pass a connection to the context, you are responsible for disposing it</title><description>Mladen,
  
How is EF to know that you didn't pass it from someplace totally different?
</description><link>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment4</link><guid>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment4</guid><pubDate>Sun, 26 Sep 2010 13:57:30 GMT</pubDate></item><item><title>Mladen commented on Entity Framework: If you pass a connection to the context, you are responsible for disposing it</title><description>Maybe i'm misunderstanding something here but how is new-ing an EntityConnection using an existing connection?
  
if you do:
  
new MyContext(new EntityConnection("name=MyConStr"))
  
shouldn't that create a new connection in that context?
  
  
maybe EF does this differently but i haven't worked with EF yet, so maybe i'm missing something here.
</description><link>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment3</link><guid>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment3</guid><pubDate>Sun, 26 Sep 2010 13:54:31 GMT</pubDate></item><item><title>configurator commented on Entity Framework: If you pass a connection to the context, you are responsible for disposing it</title><description>Indeed, classes that accept parameters should not dispose of their parameters; whoever opened the connection should be responsible for closing it.
  
  
StreamReader and StreamWriter fail miserably there. Try
  
using (MemoryStream s = new MemoryStream) {
  
  using (StreamWriter writer = new StreamWriter(s))
  
    writer.write(something);
  
  s.Seek(0);
  
  using (StreamReader reader = new StreamReader(s))
  
    reader.ReadToEnd();
  
}
</description><link>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment2</link><guid>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment2</guid><pubDate>Sat, 25 Sep 2010 21:15:04 GMT</pubDate></item><item><title>Damien Guard commented on Entity Framework: If you pass a connection to the context, you are responsible for disposing it</title><description>This applies to LINQ to SQL too - if the connection is a string it will open and close, if it is an existing connection it will not. 
  
  
[)amien
</description><link>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment1</link><guid>http://ayende.com/4640/entity-framework-if-you-pass-a-connection-to-the-context-you-are-responsible-for-disposing-it#comment1</guid><pubDate>Sat, 25 Sep 2010 17:22:24 GMT</pubDate></item></channel></rss>