defaultifempty

ASP Session variables: Is “” same as IsEmpty?

我的梦境 提交于 2019-12-10 09:23:21
问题 In ASP an uninitialized Session variable Is Empty. I know that the correct way to check for a Session value, and remove a value, is the following: IF NOT IsEmpty(Session("myVar")) THEN ' Go ahead and use Session("myVar") ... ' Now if we're all done with myVar then remove it: Session.Contents.Remove("myVar") END IF I've inherited a codebase where Application and Session variables are typically set = "" after use, and all tests for a value are of the form (Sessions("myVar") = "") . This test

Linq with DefaultIfEmpty with select new {}

浪子不回头ぞ 提交于 2019-12-07 07:56:37
问题 Linq query with default values. If in DB Table this values are not found, than default values from object should be taken, and later on new row will be added to this table. It should go like this, but this does not work: var name_country = (from m in ctx.person where (m.name == oPerson.name || m.country == oPerson.country) select new { m.name, m.country } ).DefaultIfEmpty ( oPerson.name, oPerson.country ).FirstOrDefault(); How to set this Default Values in DefaultIfEmpty??? New Edit: This is

ASP Session variables: Is “” same as IsEmpty?

一世执手 提交于 2019-12-05 14:58:41
In ASP an uninitialized Session variable Is Empty. I know that the correct way to check for a Session value, and remove a value, is the following: IF NOT IsEmpty(Session("myVar")) THEN ' Go ahead and use Session("myVar") ... ' Now if we're all done with myVar then remove it: Session.Contents.Remove("myVar") END IF I've inherited a codebase where Application and Session variables are typically set = "" after use, and all tests for a value are of the form (Sessions("myVar") = "") . This test appears to work when the Session variable has not been declared ... or maybe it's just working by dumb

Linq with DefaultIfEmpty with select new {}

时光总嘲笑我的痴心妄想 提交于 2019-12-05 12:26:13
Linq query with default values. If in DB Table this values are not found, than default values from object should be taken, and later on new row will be added to this table. It should go like this, but this does not work: var name_country = (from m in ctx.person where (m.name == oPerson.name || m.country == oPerson.country) select new { m.name, m.country } ).DefaultIfEmpty ( oPerson.name, oPerson.country ).FirstOrDefault(); How to set this Default Values in DefaultIfEmpty??? New Edit: This is what I want to make as one query: string name = (from m in ctx.person where (m.name == oPerson.name ||

Linq, OrderByDescending, First, and the nefarious DefaultIfEmpty

爱⌒轻易说出口 提交于 2019-12-01 17:04:03
问题 Hopefully this is a simple matter of me not understanding something basic. Below are two Linq statements from an application I'm working on. EDMXModel.Classes.Period p1 = entities.Periods.DefaultIfEmpty(null).OrderByDescending(ap => ap.UID).First(); EDMXModel.Classes.Period p2 = entities.Periods.OrderByDescending(ap => ap.UID).DefaultIfEmpty(null).First(); entities.Periods is a set containing two Period objects, each with a unique UID . According to everything I understand, p1 and p2 should