Just a note to self.
The Contains method on String when used in an Entity Framework “where” clause is case insensitive.
Assume the “NoteContent” column on the table “Notes” is a varchar column. If I run the following Linq query against the database where db is a DbContext then I get the same result every time.
var num = db.Notes.Where(n => n.NoteContent.Contains(“NoTe”)).Count();
var num = db.Notes.Where(n => n.NoteContent.Contains(“NOTE”)).Count();
var num = db.Notes.Where(n => n.NoteContent.Contains(“note”)).Count();
All produce the same value for “num”.
I’m making this note to self because I keep forgetting and because I keep seeing people do this:
var someString = “whatever”;
var num = db.Notes.Where(n => n.NoteContent.ToUpper().Contains(someString.ToUpper())).Count();
And, to quote Led Zepplin, “It makes me wonder.”
A friend needed the Xml Serializers dll, the one named something like “ClassLibrary1.XmlSerializers.dll”, so he went into the project properties in VS and set “Build > Generate serialization assembly” to “On”. But nothing happened. No XmlSerializers dll was created.
We hunted round for an answer and came across this: Generating an Xml Serialization assembly as part of my build.
After setting the above project property you must go into the project file in your favorite text editor and add this:
just after the line:
You should end up with something like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies> <SGenUseProxyTypes>false</SGenUseProxyTypes> </PropertyGroup>
Do that for every build configuration where you need the serializer.
Hope that helps.
If you ever see Entity Framework code that looks something like this:
SELECT 1 AS [C1], CAST(NULL AS int) AS [C2], CAST(NULL AS int) AS [C3], CAST(NULL AS varchar(1)) AS [C4] FROM ( SELECT 1 AS X ) AS [SingleRowTable1] WHERE 1 = 0
and your EF LINQ query was nothing like it (and who’s would be?), then you probably have a
in your query and the collection “somelist” is empty.
I hit this today and was scratching my head until I found this:
Hope that helps someone.
I started noticing it a couple of days ago: icons on my task bar, such as the File Explorer, stopped working and gave me that annoying “application cannot be found” message. Other programs just stopped working.
I hunted around and found that my PATH variable in a console window was only listing the additional path items from the “User” environment. The “System” (aka “Machine”) PATH environmental variable was not being appended to the front of the “User” PATH.
I tried to open “Computer > Properties > Advanced Properties” and it said it couldn’t find the Advanced Properties dialog and it gave the path to the app using “%windir%”. So I opened up a console and typed “SET” and the majority of the System environmental variables were missing.
What was going on?
I hunted and hunted and finally found this: Windows 7’s PATH and environment variables are corrupted.
Can you believe that? When your path goes over 2048 characters long the entire environmental variables handling in Windows goes haywire.
I edited my PATH and took out a bunch of duplicate entries (what added those?), got it down to a much smaller size and suddenly my Win7 machine was working perfectly again.
It seems like a serious omission that Windows gives no warning at all that there is a problem and we poor buggers have to figure out what to do.
I hope this post helps someone out there with the same headache.
If you are running Windows 8 then mounting ISO images is built in.
If you are running an earlier Windows version then you need software. The simplest I’ve found is Virtual CloneDrive. There are others that people seem to like, such as MagicISO and DaemonTools, but you aren’t supposed to install their free versions for commercial use, but Virtual CloneDrive is completely free and works great.
BTW: Don’t even think of using Microsoft’s Virtual CDRom Control Panel – it works on XP, but not on anything later without jumping through so many hoops that your legs will give way.
Martin Fowler is a cool guy and I love his sense of humor: Apple’s next connector?
If you don’t get which song the “next connector” name is coming from, then watch the video below:
A fellow developer was using Visual Studio 2010 SP1 to debug a classic ASP application. He attempted to attach to the IIS process, w3wp.exe and received the error message: “Unable to attach to process. A debugger is already attached.”
He is running Windows 7, 32 bit. (But I reproduced the error on Win7 64 bit.)
He is using IIS 7.5.
Yesterday he installed IE 10 32 bit. (Yesterday I installed IE 10 64 bit.)
We looked in Process Explorer but no debugger was running that we could see.
We tried changing the “Attach to” type in the “Attach to Process” dialog, but it had no effect.
We tried all sorts of things but nothing made any difference.
I found this forum article: Visual Studio 2010 debugger already attached classic ASP
I tried debugging the same ASP site by attaching to the IIS process, using VS 2012 and it worked perfectly.
Use VS 2012 or revert from IE 10 for Win7 to IE 9.
My fellow developer is installing VS 2012. (I don’t know why he didn’t do it already – heck, it’s worth it just for that cool Dark Theme.)
I hope that helps anyone hitting this issue.