private static string BuildSqlForDateTimeOffset(DateTimeOffset dateTimeOffset, SqlVersion sqlVersion) { var builder = new StringBuilder(); var sqlGenerator = new SqlGenerator(sqlVersion); var functionExpression = EdmFunctions.CreateDateTimeOffset( DbExpression.FromInt32(dateTimeOffset.Year), DbExpression.FromInt32(dateTimeOffset.Month), DbExpression.FromInt32(dateTimeOffset.Day), DbExpression.FromInt32(dateTimeOffset.Hour), DbExpression.FromInt32(dateTimeOffset.Minute), DbExpression.FromInt32(dateTimeOffset.Second), DbExpression.FromInt32(Convert.ToInt32(dateTimeOffset.Offset.TotalMinutes))); var sqlFragment = SqlFunctionCallHandler.GenerateFunctionCallSql( sqlGenerator, functionExpression); using (var sqlWriter = new SqlWriter(builder)) { sqlFragment.WriteSql(sqlWriter, sqlGenerator); } return(builder.ToString()); }
private static string BuildSqlForTruncateTime(DateTimeOffset dateTimeOffset, SqlVersion sqlVersion) { var builder = new StringBuilder(); var sqlGenerator = new SqlGenerator(sqlVersion); var functionExpression = EdmFunctions.TruncateTime( DbExpression.FromDateTimeOffset(dateTimeOffset)); var sqlFragment = SqlFunctionCallHandler.GenerateFunctionCallSql( sqlGenerator, functionExpression); using (var sqlWriter = new SqlWriter(builder)) { sqlFragment.WriteSql(sqlWriter, sqlGenerator); } return(builder.ToString()); }