Wednesday, August 25, 2010

ASP.NET Code Delimiters

I have been looking for these forever...

<% is the ASP.NET Page Render Function initial delimiter
<%# is the databinding ASP.NET Page Render Function initial delimiter.
<%= is the Response.Write ASP.NET Page Render Function initial delimiter
<%-- is the Comment ASP.NET Page Render Function initial delimiter

Credit where credit is due
.

Tuesday, August 24, 2010

EF and the MultipleActiveResultSets Property

Today I converted our EF models to use Configurator (custom configuration module) instead of app.config. The code looked something like this (keep in mind, this is StructureMap initialization):

config.For(Of Enterprise.eJournal.Model.IsADataContext)() _

.Use(Of Enterprise.eJournal.ContextContainer)() _

.Ctor(Of
String)("connectionString") _

.Is(String.Format("metadata=res://*/Enterprise.eJournal.Model.ContextContainer.csdl|res://*/Enterprise.eJournal.Model.ContextContainer.ssdl|res://*/Enterprise.eJournal.Model.ContextContainer.msl;provider=System.Data.SqlClient;provider connection string=""{0}"";", Configurator.Instance.BioWoRxConnectionString))


 

The BioWoRxConnectionString setting is a standard SQL Server connection string. Still, I was receiving this error:

"There is already an open DataReader associated with the Command which must be closed first."

Turns out, the MultipleActiveResultSets property has to be included in the connection string for EF to work properly, so I did this:

config.For(Of Enterprise.eJournal.Model.IsADataContext)() _

.Use(Of Enterprise.eJournal.ContextContainer)() _

.Ctor(Of
String)("connectionString") _

.Is(String.Format("metadata=res://*/Enterprise.eJournal.Model.ContextContainer.csdl|res://*/Enterprise.eJournal.Model.ContextContainer.ssdl|res://*/Enterprise.eJournal.Model.ContextContainer.msl;provider=System.Data.SqlClient;provider connection string=""{0};MultipleActiveResultSets=True"";", Configurator.Instance.BioWoRxConnectionString))


 

There you go, problem solved!

Thursday, August 19, 2010

Reconnecting to Team Foundation

For the past few days, Team Foundation source control was acting strangely – as in, when I edited a code file, it did not want to automatically check out the file, but instead asked me whether to edit in memory or make the file writable on the disk. I would then go through Team Explorer and check the file out directly from Source Control view, and make my changes, then attempt to check in. The Check In button was enabled, but I could not click it. So what the heck is going on here?

Well, at one point during the week, IIS on the Team server had been restarted. I had the project open, and was coding at that time, so Team flipped to Off-Line mode, and I continued on my way. But when the server came back online, Team did not automatically flip to On-Line mode. So, to correct it, select the Solution in Solution Explorer and go File > Source Control > Go Online.

That fixed it for me.

Friday, August 6, 2010

Unit Testing and Incomplete Tasks

OK, I'm starting to write failing unit tests for tasks I haven't completed in my project. It seems to be the only way I can keep track of what has to be done, because I can't be bothered to pick up a pen and paper...