<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx</link><description>It's usually a good idea to seperate Biz Layer Objects and Data Access Objects into seperate assemblies, but when you do that and use LINQ to SQL (.dbml) files the DataContext object default ctor uses the Settings file that is automattically generated</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#6523939</link><pubDate>Mon, 26 Nov 2007 04:04:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6523939</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;It&amp;amp;#39;s usually a good idea to seperate Biz Layer Objects and Data Access Objects into seperate assemblies&lt;/p&gt;
</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#6680616</link><pubDate>Thu, 06 Dec 2007 17:58:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6680616</guid><dc:creator>Daniel</dc:creator><description>&lt;p&gt;But what if i want to have the datacontext load its connection strings from its own app.config?&lt;/p&gt;
&lt;p&gt;because i find this approach, adding an app.config to the datacontext project and compiling the settings into the dll, really, really, really dumb...&lt;/p&gt;
&lt;p&gt;although it makes the build subject to automation/continuous integration (build process, modify settings, pack the files).&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#6680749</link><pubDate>Thu, 06 Dec 2007 18:13:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6680749</guid><dc:creator>jongallant</dc:creator><description>&lt;p&gt;Dan - An app.config file is added to Class Library projects by default when you add a new LINQ to SQL (dbml) file to the project. If you follow the steps above your app.config connectionStrings will work the same way web.config connectionStrings will.&lt;/p&gt;
&lt;p&gt;Jon&lt;/p&gt;
</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#7768194</link><pubDate>Mon, 18 Feb 2008 09:39:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7768194</guid><dc:creator>David Klein (Oakton)</dc:creator><description>&lt;p&gt;Hi Jon, - you don't need to delete code from the designer. There is a property that you can set on the dbml as per my blog entry that tells the designer not to generate the empty constructor. See&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://ddkonline.blogspot.com/2008/02/set-connection-string-in-linq-dbml-file.html"&gt;http://ddkonline.blogspot.com/2008/02/set-connection-string-in-linq-dbml-file.html&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#8343557</link><pubDate>Sat, 29 Mar 2008 18:59:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8343557</guid><dc:creator>Sebastian Paul</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;for those who don't want to change the generated code, here's another approach:&lt;/p&gt;
&lt;p&gt;Create a new cs file for the partial code.&lt;/p&gt;
&lt;p&gt;Implement OnCreated as follows:&lt;/p&gt;
&lt;p&gt;partial class MyDataContext&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	partial void OnCreated()&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		ConnectionStringSettings s = ConfigurationManager.ConnectionStrings[&amp;quot;MyConnection&amp;quot;];&lt;/p&gt;
&lt;p&gt;		if (s != null) Connection.ConnectionString = s.ConnectionString;&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;The data context will use the connection string, if found.&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#9011610</link><pubDate>Wed, 22 Oct 2008 23:00:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011610</guid><dc:creator>oyesil</dc:creator><description>&lt;p&gt;Sebastian, this is a great solution, how come I couldn't think this :).. thanks alot..&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#9178782</link><pubDate>Fri, 05 Dec 2008 09:32:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9178782</guid><dc:creator>Siva</dc:creator><description>&lt;p&gt;Thanks a lot Sabastian. very helpful and saved me a lot of time. Thanks once again&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#9553119</link><pubDate>Thu, 16 Apr 2009 19:32:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9553119</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;in dbml you can specify a different &amp;nbsp;BaseClass&lt;/p&gt;
&lt;p&gt;public class DataContextBase : System.Data.Linq.DataContext&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private static string overrideConnectionString = ConfigurationManager.ConnectionStrings[&amp;quot;CString&amp;quot;].ConnectionString;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public DataContextBase() : base(overrideConnectionString) { }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public DataContextBase(string connectionString) : base(overrideConnectionString) { }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public DataContextBase(string connectionString, System.Data.Linq.Mapping.MappingSource mappingSource) : base(overrideConnectionString, mappingSource) { }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public DataContextBase(IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base(connection, mappingSource) { }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;</description></item><item><title>re: LINQ and Web Application Connection Strings</title><link>http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx#9907741</link><pubDate>Thu, 15 Oct 2009 16:29:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907741</guid><dc:creator>Tommy Newcomb</dc:creator><description>&lt;p&gt;Thanks that works great. &amp;nbsp;I did a search on my connstring password and it was all over the place in my code using Linq to SQL. &amp;nbsp;Using the example above puts it back in 1 place in the config file. &amp;nbsp;I love Linq to SQL, but stuff like this makes me wonder about MS.&lt;/p&gt;</description></item></channel></rss>