I am using the Scott Gu Dynamic Linq
class and I am trying to convert a datetime to return a short datetime before databinding the result set to a gridview in ASP.net
. Now, I know that I can go through the gridview row databound event and check each cell to see if it is a date, and if it is, convert the date to the shortdate, however that is very cumbersome and I do not feel it is very efficient.
I am building my select statement in DynamicLinq as follows:
Filter gets its information as follows:
foreach (KeyValuePair<string,string> kvp in dictFilters)
{
filter += kvp.Key + " as " + kvp.Value.Replace("-", "_").Replace(" ", "_") + ",";
}
var result = db.ViewADHOCContractInfos.Select("new(" + filter + ")");
which gives me the result set of:
{SELECT [t0].[dtmAward] AS [Award_Date], [t0].[guidFromId], [t0].[strFundingNumber] AS [Funding_Number], [t0].[dtmCertified] AS [Certified_Date], [t0].[strFundingNumberStatus] AS [Funding_Status]
FROM [dbo].[ViewADHOCInfo] AS [t0]
}
Now what I want is this:
{SELECT Convert(VarChar, [t0].[dtmAward], 101) AS [Award_Date], [t0].[guidFromId], [t0].[strFundingNumber] AS [Funding_Number], [t0].[dtmCertified] AS [Certified_Date], [t0].[strFundingNumberStatus] AS [Funding_Status]
FROM [dbo].[ViewADHOCInfo] AS [t0]
}
Is it possible to add a SQL convert to by select statement using Dynamic Linq?