I want a Mac for Christmas:

Just kidding.

Flight scheduling system test case: flight number re-use


  • Mom books a flight from airline X, gets assigned flight number 123, arriving at airport YYZ @ 5:45am
  • Mom tells son: “my flight #123 arrives tomorrow @ 5:45am”
  • “Tomorrow” comes. Son goes online and checks flight info, which states that flight 123 is on-time.
  • 6:15am: son arrives at YYZ to pick up mom.
  • Son checks the Arrivals Fight Info board, which says flight 123 has landed. Son waits at the Arrivals Area.
  • Three hours later. Mom was “no show”. Son calls mom, who says “oh, did I say ‘today’? I meant ‘tomorrow’. Tomorrow @ 5:45am.”

Why someone would design a flight number assignment algorithm such that any X flight departing XXX for YYZ at time hh:mm, on any day of the week, would get assigned the exact same flight number, is beyond me. Are flight numbers so scarce that they have to reuse the same numbers every day?

LINQ to Entities does not recognize the method 'Boolean Like(System.String, System.String)' method

I’ve been dabbling with the ADO.NET Entity Framework in .NET 3.5, was trying to convert this SQL WHERE clause, which uses the LIKE operator, into LINQ syntax:

String strWhereClause = String.Format(CultureInfo.CurrentCulture, "Type={0} AND Name LIKE '*{0}*'", orgType, orgName);

I read somewhere which suggested to use the SqlMethods helper class. So I tried:

var objQuery = repository.Organization.Where(vendor => vendor.Type == orgType && SqlMethods.Like(vendor.Name, "”%” + orgName + “%”));

The query is targeting an Organization table. repository is an instance of an ObjectContext subclass which has been  auto generated by Visual Studio’s ADO.NET Entity Data Model wizard.  orgType and orgName are passed-in parameters.

The above approach resulted in the following runtime error (notice the redundant occurrence of the word ‘method’ in the error message):

LINQ to Entities does not recognize the method 'Boolean Like(System.String, System.String)' method, and this method cannot be translated into a store expression

I then saw a post on stackoverflow which suggested to use Contains(), StartsWith(), or EndsWith() to mimick the LIKE operator. So I tried:

var objQuery = repository.Organization.Where(vendor => vendor.Type == orgType && vendor.Name.Contains(orgName));

This works, but if orgName.Length is zero, then the query returns zero rows.  So finally, a slight mod to the above query achieved the desired effect:

var objQuery = repository.Organization.Where(vendor => vendor.Type == orgType && (orgName.Length == 0 || vendor.Name.Contains(orgName)));

“The underlying provider failed on Open.”

I’m deploying my ASP.NET app to a brand new server with a fresh install of SQL Server 2008 Express. The db connection step failed with this error:

Message: The underlying provider failed on Open.
StackTrace:  at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)

I checked the connectionString, which uses Windows authentication, and it looked fine.

Somebody suggested to Allow Remote Clients in the Network DTC Access settings. That option is already enabled on my environment.

I looked at the Event Viewer, and noticed this entry:

Event Type:    Failure Audit
Event Source:    MSSQL$MSSQL
Event Category:    Logon
Event ID:    18456
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]

So IIS is trying to access the database under the credential   'NT AUTHORITY\NETWORK SERVICE' .  I looked that the db settings via SQL Server Management Studio and, sure enough, that account is not listed as one of the users allowed to connect. So I added him. And the web app was able to connect successfully.

Which config file to put the db connectionString for ADO.NET (3.5) Entity Data Model?

Normally this goes in the App.config. VS2008 designer wizard automatically creates this file and puts it in the same location as the  assembly in which your database layer resides. But if you’re calling that assembly from an ASP.NET app, you’ll  need to move that connectionString to the Web.config.  Otherwise, you’ll get this error upon  instantiation of the ObjectContext:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.