J'utilise linqtosql et à l'intérieur de linq query, j'ai essayé de convertir la colonne datetime type en chaîne comme 'dd-MM-yy'. Cependant, je suis erreur suivante:Comment faire pour convertir datetime en chaîne dans linqtosql?
NotSupportedException: Méthode 'System.String ToString (System.String)' n'a pas de traduction pris en charge à SQL.
Voici ma requête LINQ:
from ffv in Flo_flowsheet_values
where ffv.Flowsheet_key == 2489
&& ffv.Variable_key == 70010558
&& ffv.Status == 'A'
&& ffv.Column_time >= DateTime.ParseExact("2010-06-13 00:00", "yyyy-MM-dd HH:mm", null)
&& ffv.Column_time <= DateTime.ParseExact("2010-06-13 22:59", "yyyy-MM-dd HH:mm", null)
select new {
ColumnTime = ffv.Column_time
,ColumnTimeForXCategory = ffv.Column_time.Value.ToString("dd-MM-yy") ***====> this statement invoke error***
,BTValue = Convert.ToDouble(ffv.Value) }
Pourquoi avez-vous besoin de ToString? –
La propriété ColumnTimeForXCategory est un type de chaîne pour exprimer la date de manière plus lisible. Je veux exprimer la colonne ColumnTime comme '13 -06-2010 '. C'est pourquoi j'ai utilisé la propriété ColumnTimeForXCategory. – Ray