私は次のLinqtoSqlを持っています:
var subscribers = (from s in dataContext.Employees
where s.RowType == "Edit"
select new SubscriberExportData
{
ID = s.ID.ToString(),
GroupNum = s.GroupNumber,
DivisionNum = s.DivisionNumber,
HireDate = s.HireDate != null ? Convert.ToDateTime(s.HireDate).ToShortDateString() : string.Empty,
EffDate = s.EffectiveDate != null ? Convert.ToDateTime(s.EffectiveDate).ToShortDateString() : string.Empty
}
基本的に、日付値がnullでない場合は、短い日付形式に変換します。しかし、次のエラーが発生します。
System.InvalidOperationExceptionが処理されませんでしたMessage=式を変換できませんでした'Table(Employee).Where(s =>(s.RowType == "Edit"))。Select(s => new SubscriberExportData(){HireDate = IIF((s .HireDate!= null)、ToDateTime(Convert(s.HireDate))。ToShortDateString()、Invoke(value(System.Func`1 [System.String])))、EffDate = IIF((s.EffectiveDate!= null )、ToDateTime(Convert(s.EffectiveDate))。ToShortDateString)'をSQLに変換し、ローカル式として処理できませんでした。Source= System.Data.Linq
解決方法を教えてください。