Did you try this class?
public class AppCount
{
public int? Count { get; set; }
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
currently var appCountResult throws exception when the result is NULL because it accepts INTEGER.
Need inputs to change the var appCountResult condition so that it can accept to return NULL (or) INTEGER value based on the var appCountQuery .
AppResponse.cs file:
public class AppCount
{
public int Count { get; set; }
}
Helper.cs file:
var appCountQuery = $"(SELECT MAX(COUNT) AS COUNT FROM (SELECT COUNT(DISTINCT WN.APPKEY) AS COUNT FROM DEV.DBO.VW_NUMBER WN
WHERE WN.ANUMBER IN ('MLSR12677','S448904')" +
$" AND WN.UNITKEY IN (SELECT IC.UNITKEY FROM DEV.DBO.VW_DATA IC WHERE IC.UNITNAME = 'MAS') " +
$" GROUP BY WN.DEPTKEY, WN.ANUMBER HAVING COUNT(DISTINCT WN.APPKEY) = 1) X )";
var appCountResult = (await _cache.GetAsync(agents_CacheKeyPrefix,
TimeSpan.FromMinutes(CACHE_TIME),
() => _Client.QueryAsync<AppCount>(appCountQuery, ct: _cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult()
).ConfigureAwait(false)).FirstOrDefault();
if ( appCountResult == null )
{
return new AppResponse()
{
Title = "No app count."
};
}
else if (agentCountResult.Count > 1)
{
return new AppResponse()
{
Title = "Unable to retrieve app data due to conflict."
};
}
else
{
return new AppResponse()
{
Title = "No app data."
};
}
Thank you.
Did you try this class?
public class AppCount
{
public int? Count { get; set; }
}