Getting weird exception creating anonymous type after recreating Linq to SQL dbml (Or possibly after moving to .NET 3.5 SP1?

The answer is to cast the expression to a nullable type, which lets the anonymous type know to expect it. I suspect this was a change with SP1 EquipmentTypeID = ((int? )D.DMXDeviceModel.DMXDeviceClass.

DMXEquipmentType. ID).

The answer is to cast the expression to a nullable type, which lets the anonymous type know to expect it. I suspect this was a change with SP1. EquipmentTypeID = ((int?)D.DMXDeviceModel.DMXDeviceClass.

DMXEquipmentType. ID).

Also, found that "as" doesn't work: "EquipmentTypeID = D.DMXDeviceModel.DMXDeviceClass. DMXEquipmentType. ID as int?".

You must use the cast operator as Telos says. – Joseph Kingry Mar 11 '09 at 17:51.

We moved the . Dbml file out of the website and into another assembly so it could be shared across multiple applications. The problem is that now I'm getting an error that doesn't make any sense.

There are several fields queried like that, and now they are all throwing the following exception: The null value cannot be assigned to a member with type System. Int32 which is a non-nullable value type. The ID field(s) in question are not nullable in the database, or in the Linq entity class.

Everything matches up correctly, so there shouldn't even be a null value anywhere in there. The code also worked perfectly before "moving" the . Dbml file to another assembly.

Actually, we didn't move it because there were some other errors and problems when we tried. I recreated it in the new assembly, but that shouldn't matter because it was generated from the same database. I've also tried selecting anything where D.DMXDeviceModel.DMXDeviceClass.DMXEquipmentType.ID is null, and no results were returned.

EDIT: by request here is the xml for the dbml file. It turns out anything referenced through DMXDeviceModel throws this exception when DeviceModelID is null. It seems to be a problem creating the anonymous type to handle a null DeviceModelID... but why wasn't it happening before?

EDIT EDIT: You know, I also moved to . NET 3.5 SP1 and that changed some of the other behavior on the site. Maybe that's the real culprit here.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions