1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
|
//---------------------------------------------------------------------
// <copyright file="EdmFunctions.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//
// @owner Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------
namespace System.Data.Common.CommandTrees.ExpressionBuilder
{
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Metadata.Edm;
using System.Diagnostics;
/// <summary>
/// Provides an API to construct <see cref="DbExpression"/>s that invoke canonical EDM functions, and allows that API to be accessed as extension methods on the expression type itself.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
public static class EdmFunctions
{
#region Private Implementation
private static EdmFunction ResolveCanonicalFunction(string functionName, TypeUsage[] argumentTypes)
{
Debug.Assert(!string.IsNullOrEmpty(functionName), "Function name must not be null");
List<EdmFunction> functions = new List<EdmFunction>(
System.Linq.Enumerable.Where(
EdmProviderManifest.Instance.GetStoreFunctions(),
func => string.Equals(func.Name, functionName, StringComparison.Ordinal))
);
EdmFunction foundFunction = null;
bool ambiguous = false;
if (functions.Count > 0)
{
foundFunction = EntitySql.FunctionOverloadResolver.ResolveFunctionOverloads(functions, argumentTypes, false, out ambiguous);
if (ambiguous)
{
throw EntityUtil.Argument(Strings.Cqt_Function_CanonicalFunction_AmbiguousMatch(functionName));
}
}
if (foundFunction == null)
{
throw EntityUtil.Argument(Strings.Cqt_Function_CanonicalFunction_NotFound(functionName));
}
return foundFunction;
}
internal static DbFunctionExpression InvokeCanonicalFunction(string functionName, params DbExpression[] arguments)
{
TypeUsage[] argumentTypes = new TypeUsage[arguments.Length];
for (int idx = 0; idx < arguments.Length; idx++)
{
Debug.Assert(arguments[idx] != null, "Ensure arguments are non-null before calling InvokeCanonicalFunction");
argumentTypes[idx] = arguments[idx].ResultType;
}
EdmFunction foundFunction = ResolveCanonicalFunction(functionName, argumentTypes);
return DbExpressionBuilder.Invoke(foundFunction, arguments);
}
#endregion
#region Aggregate functions - Average, Count, LongCount, Max, Min, Sum, StDev, StDevP, Var, VarP
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Avg' function over the
/// specified collection. The result type of the expression is the same as the element type of the collection.
/// </summary>
/// <param name="collection">An expression that specifies the collection from which the average value should be computed</param>
/// <returns>A new DbFunctionExpression that produces the average value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Avg' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Average(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Avg", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Count' function over the
/// specified collection. The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="collection">An expression that specifies the collection over which the count value should be computed.</param>
/// <returns>A new DbFunctionExpression that produces the count value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Count' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Count(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Count", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'BigCount' function over the
/// specified collection. The result type of the expression is Edm.Int64.
/// </summary>
/// <param name="collection">An expression that specifies the collection over which the count value should be computed.</param>
/// <returns>A new DbFunctionExpression that produces the count value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'BigCount' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression LongCount(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("BigCount", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Max' function over the
/// specified collection. The result type of the expression is the same as the element type of the collection.
/// </summary>
/// <param name="collection">An expression that specifies the collection from which the maximum value should be retrieved</param>
/// <returns>A new DbFunctionExpression that produces the maximum value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Max' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Max(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Max", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Min' function over the
/// specified collection. The result type of the expression is the same as the element type of the collection.
/// </summary>
/// <param name="collection">An expression that specifies the collection from which the minimum value should be retrieved</param>
/// <returns>A new DbFunctionExpression that produces the minimum value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Min' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Min(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Min", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Sum' function over the
/// specified collection. The result type of the expression is the same as the element type of the collection.
/// </summary>
/// <param name="collection">An expression that specifies the collection from which the sum should be computed</param>
/// <returns>A new DbFunctionExpression that produces the sum.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Sum' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Sum(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Sum", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'StDev' function over the
/// non-null members of the specified collection. The result type of the expression is Edm.Double.
/// </summary>
/// <param name="collection">An expression that specifies the collection for which the standard deviation should be computed</param>
/// <returns>A new DbFunctionExpression that produces the standard deviation value over non-null members of the collection.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'StDev' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "St")]
public static DbFunctionExpression StDev(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("StDev", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'StDevP' function over the
/// population of the specified collection. The result type of the expression is Edm.Double.
/// </summary>
/// <param name="collection">An expression that specifies the collection for which the standard deviation should be computed</param>
/// <returns>A new DbFunctionExpression that produces the standard deviation value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'StDevP' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "St")]
public static DbFunctionExpression StDevP(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("StDevP", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Var' function over the
/// non-null members of the specified collection. The result type of the expression is Edm.Double.
/// </summary>
/// <param name="collection">An expression that specifies the collection for which the statistical variance should be computed</param>
/// <returns>A new DbFunctionExpression that produces the statistical variance value for the non-null members of the collection.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Var' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression Var(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("Var", collection);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'VarP' function over the
/// population of the specified collection. The result type of the expression Edm.Double.
/// </summary>
/// <param name="collection">An expression that specifies the collection for which the statistical variance should be computed</param>
/// <returns>A new DbFunctionExpression that produces the statistical variance value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'VarP' function accepts an argument with the result type of <paramref name="collection"/>.</exception>
public static DbFunctionExpression VarP(this DbExpression collection)
{
EntityUtil.CheckArgumentNull(collection, "collection");
return InvokeCanonicalFunction("VarP", collection);
}
#endregion
#region String functions - Concat, Contains, EndsWith, IndexOf, Left, Length, LTrim, Replace, Reverse, Right, RTrim, StartsWith, Substring, ToUpper, ToLower, Trim
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Concat' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// string.
/// </summary>
/// <param name="string1">An expression that specifies the string that should appear first in the concatenated result string.</param>
/// <param name="string2">An expression that specifies the string that should appear second in the concatenated result string.</param>
/// <returns>A new DbFunctionExpression that produces the concatenated string.</returns>
/// <exception cref="ArgumentNullException"><paramref name="string1"/> or <paramref name="string2"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Concat' function accepts arguments with the result types of <paramref name="string1"/> and <paramref name="string2"/>.</exception>
public static DbFunctionExpression Concat(this DbExpression string1, DbExpression string2)
{
EntityUtil.CheckArgumentNull(string1, "string1");
EntityUtil.CheckArgumentNull(string2, "string2");
return InvokeCanonicalFunction("Concat", string1, string2);
}
//
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Contains' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// Boolean.
/// </summary>
/// <param name="searchedString">An expression that specifies the string to search for any occurence of <paramref name="searchedForString"/>.</param>
/// <param name="searchedForString">An expression that specifies the string to search for in <paramref name="searchedString"/>.</param>
/// <returns>A new DbFunctionExpression that returns a Boolean value indicating whether or not <paramref name="searchedForString"/> occurs within <paramref name="searchedString"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="searchedString"/> or <paramref name="searchedForString"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Contains' function accepts arguments with the result types of <paramref name="searchedString"/> and <paramref name="searchedForString"/>.</exception>
public static DbExpression Contains(this DbExpression searchedString, DbExpression searchedForString)
{
EntityUtil.CheckArgumentNull(searchedString, "searchedString");
EntityUtil.CheckArgumentNull(searchedForString, "searchedForString");
return InvokeCanonicalFunction("Contains", searchedString, searchedForString);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'EndsWith' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// Boolean.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string to check for the specified <param name="suffix">.</param>
/// <param name="suffix">An expression that specifies the suffix for which <paramref name="stringArgument"/> should be checked.</param>
/// <returns>A new DbFunctionExpression that indicates whether <paramref name="stringArgument"/> ends with <paramref name="suffix"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> or <paramref name="suffix"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'EndsWith' function accepts arguments with the result types of <paramref name="stringArgument"/> and <paramref name="suffix"/>.</exception>
public static DbFunctionExpression EndsWith(this DbExpression stringArgument, DbExpression suffix)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(suffix, "suffix");
return InvokeCanonicalFunction("EndsWith", stringArgument, suffix);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'IndexOf' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// Edm.Int32.
/// </summary>
/// <remarks>The index returned by IndexOf is <b>1-based</b>.</remarks>
/// <param name="searchString">An expression that specifies the string to search for <paramref name="stringToFind"/>.</param>
/// <param name="stringToFind">An expression that specifies the string to locate within <paramref name="searchString"/> should be checked.</param>
/// <returns>A new DbFunctionExpression that returns the first index of <paramref name="stringToFind"/> in <paramref name="searchString"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="searchString"/> or <paramref name="stringToFind"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'IndexOf' function accepts arguments with the result types of <paramref name="searchString"/> and <paramref name="stringToFind"/>.</exception>
public static DbFunctionExpression IndexOf(this DbExpression searchString, DbExpression stringToFind)
{
EntityUtil.CheckArgumentNull(searchString, "searchString");
EntityUtil.CheckArgumentNull(stringToFind, "stringToFind");
return InvokeCanonicalFunction("IndexOf", stringToFind, searchString);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Left' function with the
/// specified arguments, which must have a string and integer numeric result type. The result type of the expression is
/// string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string from which to extract the leftmost substring.</param>
/// <param name="length">An expression that specifies the length of the leftmost substring to extract from <paramref name="stringArgument"/>.</param>
/// <returns>A new DbFunctionExpression that returns the the leftmost substring of length <paramref name="length"/> from <paramref name="stringArgument"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> or <paramref name="length"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Left' function accepts arguments with the result types of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression Left(this DbExpression stringArgument, DbExpression length)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(length, "length");
return InvokeCanonicalFunction("Left", stringArgument, length);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Length' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string for which the length should be computed.</param>
/// <returns>A new DbFunctionExpression that returns the the length of <paramref name="stringArgument"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Length' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression Length(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("Length", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Replace' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string in which to perform the replacement operation</param>
/// <param name="toReplace">An expression that specifies the string to replace</param>
/// <param name="replacement">An expression that specifies the replacement string</param>
/// <returns>A new DbFunctionExpression than returns a new string based on <paramref name="stringArgument"/> where every occurence of <paramref name="toReplace"/> is replaced by <paramref name="replacement"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/>, <paramref name="toReplace"/> or <paramref name="replacement"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Length' function accepts arguments with the result types of <paramref name="stringArgument"/>, <paramref name="toReplace"/> and <paramref name="replacement"/>.</exception>
public static DbFunctionExpression Replace(this DbExpression stringArgument, DbExpression toReplace, DbExpression replacement)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(toReplace, "toReplace");
EntityUtil.CheckArgumentNull(replacement, "replacement");
return InvokeCanonicalFunction("Replace", stringArgument, toReplace, replacement);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Reverse' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string to reverse.</param>
/// <returns>A new DbFunctionExpression that produces the reversed value of <paramref name="stringArgument"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Reverse' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression Reverse(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("Reverse", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Right' function with the
/// specified arguments, which must have a string and integer numeric result type. The result type of the expression is
/// string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string from which to extract the rightmost substring.</param>
/// <param name="length">An expression that specifies the length of the rightmost substring to extract from <paramref name="stringArgument"/>.</param>
/// <returns>A new DbFunctionExpression that returns the the rightmost substring of length <paramref name="length"/> from <paramref name="stringArgument"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> or <paramref name="length"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Right' function accepts arguments with the result types of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression Right(this DbExpression stringArgument, DbExpression length)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(length, "length");
return InvokeCanonicalFunction("Right", stringArgument, length);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'StartsWith' function with the
/// specified arguments, which must each have a string result type. The result type of the expression is
/// Boolean.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string to check for the specified <param name="prefix">.</param>
/// <param name="suffix">An expression that specifies the prefix for which <paramref name="stringArgument"/> should be checked.</param>
/// <returns>A new DbFunctionExpression that indicates whether <paramref name="stringArgument"/> starts with <paramref name="prefix"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> or <paramref name="prefix"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'StartsWith' function accepts arguments with the result types of <paramref name="stringArgument"/> and <paramref name="prefix"/>.</exception>
public static DbFunctionExpression StartsWith(this DbExpression stringArgument, DbExpression prefix)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(prefix, "prefix");
return InvokeCanonicalFunction("StartsWith", stringArgument, prefix);
}
//
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Substring' function with the
/// specified arguments, which must have a string and integer numeric result types. The result type of the
/// expression is string.
/// </summary>
/// <remarks>Substring requires that the index specified by <paramref name="start"/> be <b>1-based</b>.</remarks>
/// <param name="stringArgument">An expression that specifies the string from which to extract the substring.</param>
/// <param name="start">An expression that specifies the starting index from which the substring should be taken.</param>
/// <param name="length">An expression that specifies the length of the substring.</param>
/// <returns>A new DbFunctionExpression that returns the substring of length <paramref name="length"/> from <paramref name="stringArgument"/> starting at <paramref name="start"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/>, <paramref name="start"/> or <paramref name="length"/>is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Substring' function accepts arguments with the result types of <paramref name="stringArgument"/>, <paramref name="start"/> and <paramref name="length"/>.</exception>
public static DbFunctionExpression Substring(this DbExpression stringArgument, DbExpression start, DbExpression length)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
EntityUtil.CheckArgumentNull(start, "start");
EntityUtil.CheckArgumentNull(length, "length");
return InvokeCanonicalFunction("Substring", stringArgument, start, length);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'ToLower' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string that should be converted to lower case.</param>
/// <returns>A new DbFunctionExpression that returns value of <paramref name="stringArgument"/> converted to lower case.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'ToLower' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression ToLower(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("ToLower", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'ToUpper' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string that should be converted to upper case.</param>
/// <returns>A new DbFunctionExpression that returns value of <paramref name="stringArgument"/> converted to upper case.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'ToUpper' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression ToUpper(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("ToUpper", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Trim' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string from which leading and trailing space should be removed.</param>
/// <returns>A new DbFunctionExpression that returns value of <paramref name="stringArgument"/> with leading and trailing space removed.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Trim' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression Trim(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("Trim", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'RTrim' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string from which trailing space should be removed.</param>
/// <returns>A new DbFunctionExpression that returns value of <paramref name="stringArgument"/> with trailing space removed.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'RTrim' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression TrimEnd(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("RTrim", stringArgument);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'LTrim' function with the
/// specified argument, which must have a string result type. The result type of the expression is
/// also string.
/// </summary>
/// <param name="stringArgument">An expression that specifies the string from which leading space should be removed.</param>
/// <returns>A new DbFunctionExpression that returns value of <paramref name="stringArgument"/> with leading space removed.</returns>
/// <exception cref="ArgumentNullException"><paramref name="stringArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'LTrim' function accepts an argument with the result type of <paramref name="stringArgument"/>.</exception>
public static DbFunctionExpression TrimStart(this DbExpression stringArgument)
{
EntityUtil.CheckArgumentNull(stringArgument, "stringArgument");
return InvokeCanonicalFunction("LTrim", stringArgument);
}
#endregion
#region Date/Time member access methods - Year, Month, Day, DayOfYear, Hour, Minute, Second, Millisecond, GetTotalOffsetMinutes
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Year' function with the
/// specified argument, which must have a DateTime or DateTimeOffset result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue">An expression that specifies the value from which the year should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer year value from <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Year' function accepts an argument with the result type of <paramref name="dateValue"/>.</exception>
public static DbFunctionExpression Year(this DbExpression dateValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
return InvokeCanonicalFunction("Year", dateValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Month' function with the
/// specified argument, which must have a DateTime or DateTimeOffset result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue">An expression that specifies the value from which the month should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer month value from <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Month' function accepts an argument with the result type of <paramref name="dateValue"/>.</exception>
public static DbFunctionExpression Month(this DbExpression dateValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
return InvokeCanonicalFunction("Month", dateValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Day' function with the
/// specified argument, which must have a DateTime or DateTimeOffset result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue">An expression that specifies the value from which the day should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer day value from <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Day' function accepts an argument with the result type of <paramref name="dateValue"/>.</exception>
public static DbFunctionExpression Day(this DbExpression dateValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
return InvokeCanonicalFunction("Day", dateValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DayOfYear' function with the
/// specified argument, which must have a DateTime or DateTimeOffset result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue">An expression that specifies the value from which the day within the year should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer day of year value from <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DayOfYear' function accepts an argument with the result type of <paramref name="dateValue"/>.</exception>
public static DbFunctionExpression DayOfYear(this DbExpression dateValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
return InvokeCanonicalFunction("DayOfYear", dateValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Hour' function with the
/// specified argument, which must have a DateTime, DateTimeOffset or Time result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue">An expression that specifies the value from which the hour should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer hour value from <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Hour' function accepts an argument with the result type of <paramref name="timeValue"/>.</exception>
public static DbFunctionExpression Hour(this DbExpression timeValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
return InvokeCanonicalFunction("Hour", timeValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Minute' function with the
/// specified argument, which must have a DateTime, DateTimeOffset or Time result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue">An expression that specifies the value from which the minute should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer minute value from <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Minute' function accepts an argument with the result type of <paramref name="timeValue"/>.</exception>
public static DbFunctionExpression Minute(this DbExpression timeValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
return InvokeCanonicalFunction("Minute", timeValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Second' function with the
/// specified argument, which must have a DateTime, DateTimeOffset or Time result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue">An expression that specifies the value from which the second should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer second value from <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Second' function accepts an argument with the result type of <paramref name="timeValue"/>.</exception>
public static DbFunctionExpression Second(this DbExpression timeValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
return InvokeCanonicalFunction("Second", timeValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Millisecond' function with the
/// specified argument, which must have a DateTime, DateTimeOffset or Time result type. The result type of
/// the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue">An expression that specifies the value from which the millisecond should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the integer millisecond value from <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Millisecond' function accepts an argument with the result type of <paramref name="timeValue"/>.</exception>
public static DbFunctionExpression Millisecond(this DbExpression timeValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
return InvokeCanonicalFunction("Millisecond", timeValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'GetTotalOffsetMinutes' function with the
/// specified argument, which must have a DateTimeOffset result type. The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="dateTimeOffsetArgument">An expression that specifies the DateTimeOffset value from which the minute offset from GMT should be retrieved.</param>
/// <returns>A new DbFunctionExpression that returns the number of minutes <paramref name="dateTimeOffsetArgument"/> is offset from GMT.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateTimeOffsetArgument"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'GetTotalOffsetMinutes' function accepts an argument with the result type of <paramref name="dateTimeOffsetArgument"/>.</exception>
public static DbFunctionExpression GetTotalOffsetMinutes(this DbExpression dateTimeOffsetArgument)
{
EntityUtil.CheckArgumentNull(dateTimeOffsetArgument, "dateTimeOffsetArgument");
return InvokeCanonicalFunction("GetTotalOffsetMinutes", dateTimeOffsetArgument);
}
#endregion
#region Date/Time creation methods - CurrentDateTime, CurrentDateTimeOffset, CurrentUtcDateTime, CreateDateTime, CreateDateTimeOffset, CreateTime, TruncateTime
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CurrentDateTime' function.
/// </summary>
/// <returns>A new DbFunctionExpression that returns the current date and time as an Edm.DateTime instance.</returns>
public static DbFunctionExpression CurrentDateTime()
{
return InvokeCanonicalFunction("CurrentDateTime");
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CurrentDateTimeOffset' function.
/// </summary>
/// <returns>A new DbFunctionExpression that returns the current date and time as an Edm.DateTimeOffset instance.</returns>
public static DbFunctionExpression CurrentDateTimeOffset()
{
return InvokeCanonicalFunction("CurrentDateTimeOffset");
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CurrentUtcDateTime' function.
/// </summary>
/// <returns>A new DbFunctionExpression that returns the current UTC date and time as an Edm.DateTime instance.</returns>
public static DbFunctionExpression CurrentUtcDateTime()
{
return InvokeCanonicalFunction("CurrentUtcDateTime");
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'TruncateTime' function with the
/// specified argument, which must have a DateTime or DateTimeOffset result type. The result type of the
/// expression is the same as the result type of <paramref name="dateValue"/>.
/// </summary>
/// <param name="dateValue">An expression that specifies the value for which the time portion should be truncated.</param>
/// <returns>A new DbFunctionExpression that returns the value of <paramref name="dateValue"/> with time set to zero.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'TruncateTime' function accepts an argument with the result type of <paramref name="dateValue"/>.</exception>
public static DbFunctionExpression TruncateTime(this DbExpression dateValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
return InvokeCanonicalFunction("TruncateTime", dateValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CreateDateTime' function with the
/// specified arguments. <paramref name="second"/> must have a result type of Edm.Double, while all other arguments
/// must have a result type of Edm.Int32. The result type of the expression is Edm.DateTime.
/// </summary>
/// <param name="year">An expression that provides the year value for the new DateTime instance.</param>
/// <param name="month">An expression that provides the month value for the new DateTime instance.</param>
/// <param name="day">An expression that provides the day value for the new DateTime instance.</param>
/// <param name="hour">An expression that provides the hour value for the new DateTime instance.</param>
/// <param name="minute">An expression that provides the minute value for the new DateTime instance.</param>
/// <param name="second">An expression that provides the second value for the new DateTime instance.</param>
/// <returns>A new DbFunctionExpression that returns a new DateTime based on the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="year"/>, <paramref name="month"/>, <paramref name="day"/>, <paramref name="hour"/>, <paramref name="minute"/>, or <paramref name="second"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'CreateDateTime' function accepts arguments with the result types of <paramref name="year"/>, <paramref name="month"/>, <paramref name="day"/>, <paramref name="hour"/>, <paramref name="minute"/>, and <paramref name="second"/>.</exception>
public static DbFunctionExpression CreateDateTime(DbExpression year, DbExpression month, DbExpression day, DbExpression hour, DbExpression minute, DbExpression second)
{
EntityUtil.CheckArgumentNull(year, "year");
EntityUtil.CheckArgumentNull(month, "month");
EntityUtil.CheckArgumentNull(day, "day");
EntityUtil.CheckArgumentNull(hour, "hour");
EntityUtil.CheckArgumentNull(minute, "minute");
EntityUtil.CheckArgumentNull(second, "second");
return InvokeCanonicalFunction("CreateDateTime", year, month, day, hour, minute, second);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CreateDateTimeOffset' function with the
/// specified arguments. <paramref name="second"/> must have a result type of Edm.Double, while all other arguments
/// must have a result type of Edm.Int32. The result type of the expression is Edm.DateTimeOffset.
/// </summary>
/// <param name="year">An expression that provides the year value for the new DateTimeOffset instance.</param>
/// <param name="month">An expression that provides the month value for the new DateTimeOffset instance.</param>
/// <param name="day">An expression that provides the day value for the new DateTimeOffset instance.</param>
/// <param name="hour">An expression that provides the hour value for the new DateTimeOffset instance.</param>
/// <param name="minute">An expression that provides the minute value for the new DateTimeOffset instance.</param>
/// <param name="second">An expression that provides the second value for the new DateTimeOffset instance.</param>
/// <param name="timeZoneOffset">An expression that provides the number of minutes in the time zone offset value for the new DateTimeOffset instance.</param>
/// <returns>A new DbFunctionExpression that returns a new DateTimeOffset based on the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="year"/>, <paramref name="month"/>, <paramref name="day"/>, <paramref name="hour"/>, <paramref name="minute"/>, <paramref name="second"/> or <paramref name="timeZoneOffset"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'CreateDateTimeOffset' function accepts arguments with the result types of <paramref name="year"/>, <paramref name="month"/>, <paramref name="day"/>, <paramref name="hour"/>, <paramref name="minute"/>, <paramref name="second"/> and <paramref name="timeZoneOffset"/>.</exception>
public static DbFunctionExpression CreateDateTimeOffset(DbExpression year, DbExpression month, DbExpression day, DbExpression hour, DbExpression minute, DbExpression second, DbExpression timeZoneOffset)
{
EntityUtil.CheckArgumentNull(year, "year");
EntityUtil.CheckArgumentNull(month, "month");
EntityUtil.CheckArgumentNull(day, "day");
EntityUtil.CheckArgumentNull(hour, "hour");
EntityUtil.CheckArgumentNull(minute, "minute");
EntityUtil.CheckArgumentNull(second, "second");
EntityUtil.CheckArgumentNull(timeZoneOffset, "timeZoneOffset");
return InvokeCanonicalFunction("CreateDateTimeOffset", year, month, day, hour, minute, second, timeZoneOffset);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'CreateTime' function with the
/// specified arguments. <paramref name="second"/> must have a result type of Edm.Double, while all other arguments
/// must have a result type of Edm.Int32. The result type of the expression is Edm.Time.
/// </summary>
/// <param name="hour">An expression that provides the hour value for the new DateTime instance.</param>
/// <param name="minute">An expression that provides the minute value for the new DateTime instance.</param>
/// <param name="second">An expression that provides the second value for the new DateTime instance.</param>
/// <returns>A new DbFunctionExpression that returns a new Time based on the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="hour"/>, <paramref name="minute"/>, or <paramref name="second"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'CreateTime' function accepts arguments with the result types of <paramref name="hour"/>, <paramref name="minute"/>, and <paramref name="second"/>.</exception>
public static DbFunctionExpression CreateTime(DbExpression hour, DbExpression minute, DbExpression second)
{
EntityUtil.CheckArgumentNull(hour, "hour");
EntityUtil.CheckArgumentNull(minute, "minute");
EntityUtil.CheckArgumentNull(second, "second");
return InvokeCanonicalFunction("CreateTime", hour, minute, second);
}
#endregion
#region Date/Time addition - AddYears, AddMonths, AddDays, AddHours, AddMinutes, AddSeconds, AddMilliseconds, AddMicroseconds, AddNanoseconds
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddYears' function with the
/// specified arguments, which must have DateTime or DateTimeOffset and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="dateValue"/>.
/// </summary>
/// <param name="dateValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of years to add to <paramref name="dateValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of years specified by <paramref name="addValue"/> to the value specified by <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddYears' function accepts arguments with the result types of <paramref name="dateValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddYears(this DbExpression dateValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddYears", dateValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddMonths' function with the
/// specified arguments, which must have DateTime or DateTimeOffset and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="dateValue"/>.
/// </summary>
/// <param name="dateValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of months to add to <paramref name="dateValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of months specified by <paramref name="addValue"/> to the value specified by <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddMonths' function accepts arguments with the result types of <paramref name="dateValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddMonths(this DbExpression dateValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddMonths", dateValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddDays' function with the
/// specified arguments, which must have DateTime or DateTimeOffset and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="dateValue"/>.
/// </summary>
/// <param name="dateValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of days to add to <paramref name="dateValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of days specified by <paramref name="addValue"/> to the value specified by <paramref name="dateValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddDays' function accepts arguments with the result types of <paramref name="dateValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddDays(this DbExpression dateValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(dateValue, "dateValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddDays", dateValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddHours' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of hours to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of hours specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddHours' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddHours(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddHours", timeValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddMinutes' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of minutes to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of minutes specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddMinutes' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddMinutes(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddMinutes", timeValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddSeconds' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of seconds to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of seconds specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddSeconds' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddSeconds(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddSeconds", timeValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddMilliseconds' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of milliseconds to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of milliseconds specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddMilliseconds' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddMilliseconds(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddMilliseconds", timeValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddMicroseconds' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of microseconds to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of microseconds specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddMicroseconds' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddMicroseconds(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddMicroseconds", timeValue, addValue);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'AddNanoseconds' function with the
/// specified arguments, which must have DateTime, DateTimeOffset or Time, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="timeValue"/>.
/// </summary>
/// <param name="timeValue">An expression that specifies the value to which <paramref name="addValue"/>should be added.</param>
/// <param name="addValue">An expression that specifies the number of nanoseconds to add to <paramref name="timeValue"/>.</param>
/// <returns>A new DbFunctionExpression that adds the number of nanoseconds specified by <paramref name="addValue"/> to the value specified by <paramref name="timeValue"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue"/> or <paramref name="addValue"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'AddNanoseconds' function accepts arguments with the result types of <paramref name="timeValue"/> and <paramref name="addValue"/>.</exception>
public static DbFunctionExpression AddNanoseconds(this DbExpression timeValue, DbExpression addValue)
{
EntityUtil.CheckArgumentNull(timeValue, "timeValue");
EntityUtil.CheckArgumentNull(addValue, "addValue");
return InvokeCanonicalFunction("AddNanoseconds", timeValue, addValue);
}
#endregion
#region Date/Time difference - DiffYears, DiffMonths, DiffDays, DiffHours, DiffMinutes, DiffSeconds, DiffMilliseconds, DiffMicroseconds, DiffNanoseconds
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffYears' function with the
/// specified arguments, which must each have a DateTime or DateTimeOffset result type. The result type of
/// <paramref name="dateValue1"/> must match the result type of <paramref name="dateValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue1">An expression that specifies the first DateTime or DateTimeOffset value.</param>
/// <param name="dateValue2">An expression that specifies the DateTime or DateTimeOffset for which the year difference from <paramref name="dateValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the year difference between <param name="dateValue1"> and <param name="dateValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue1"/> or <paramref name="dateValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffYears' function accepts arguments with the result types of <paramref name="dateValue1"/> and <paramref name="dateValue2"/>.</exception>
public static DbFunctionExpression DiffYears(this DbExpression dateValue1, DbExpression dateValue2)
{
EntityUtil.CheckArgumentNull(dateValue1, "dateValue1");
EntityUtil.CheckArgumentNull(dateValue2, "dateValue2");
return InvokeCanonicalFunction("DiffYears", dateValue1, dateValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffMonths' function with the
/// specified arguments, which must each have a DateTime or DateTimeOffset result type. The result type of
/// <paramref name="dateValue1"/> must match the result type of <paramref name="dateValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue1">An expression that specifies the first DateTime or DateTimeOffset value.</param>
/// <param name="dateValue2">An expression that specifies the DateTime or DateTimeOffset for which the month difference from <paramref name="dateValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the month difference between <param name="dateValue1"> and <param name="dateValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue1"/> or <paramref name="dateValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffMonths' function accepts arguments with the result types of <paramref name="dateValue1"/> and <paramref name="dateValue2"/>.</exception>
public static DbFunctionExpression DiffMonths(this DbExpression dateValue1, DbExpression dateValue2)
{
EntityUtil.CheckArgumentNull(dateValue1, "dateValue1");
EntityUtil.CheckArgumentNull(dateValue2, "dateValue2");
return InvokeCanonicalFunction("DiffMonths", dateValue1, dateValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffDays' function with the
/// specified arguments, which must each have a DateTime or DateTimeOffset result type. The result type of
/// <paramref name="dateValue1"/> must match the result type of <paramref name="dateValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="dateValue1">An expression that specifies the first DateTime or DateTimeOffset value.</param>
/// <param name="dateValue2">An expression that specifies the DateTime or DateTimeOffset for which the day difference from <paramref name="dateValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the day difference between <param name="dateValue1"> and <param name="dateValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="dateValue1"/> or <paramref name="dateValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffDays' function accepts arguments with the result types of <paramref name="dateValue1"/> and <paramref name="dateValue2"/>.</exception>
public static DbFunctionExpression DiffDays(this DbExpression dateValue1, DbExpression dateValue2)
{
EntityUtil.CheckArgumentNull(dateValue1, "dateValue1");
EntityUtil.CheckArgumentNull(dateValue2, "dateValue2");
return InvokeCanonicalFunction("DiffDays", dateValue1, dateValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffHours' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the hour difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the hour difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffHours' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffHours(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffHours", timeValue1, timeValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffMinutes' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the minute difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the minute difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffMinutes' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffMinutes(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffMinutes", timeValue1, timeValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffSeconds' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the second difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the second difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffSeconds' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffSeconds(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffSeconds", timeValue1, timeValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffMilliseconds' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the millisecond difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the millisecond difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffMilliseconds' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffMilliseconds(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffMilliseconds", timeValue1, timeValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffMicroseconds' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the microsecond difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the microsecond difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffMicroseconds' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffMicroseconds(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffMicroseconds", timeValue1, timeValue2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'DiffNanoseconds' function with the
/// specified arguments, which must each have a DateTime, DateTimeOffset or Time result type. The result type of
/// <paramref name="timeValue1"/> must match the result type of <paramref name="timeValue2"/>.
/// The result type of the expression is Edm.Int32.
/// </summary>
/// <param name="timeValue1">An expression that specifies the first DateTime, DateTimeOffset or Time value.</param>
/// <param name="timeValue2">An expression that specifies the DateTime, DateTimeOffset or Time for which the nanosecond difference from <paramref name="timeValue1"/> should be calculated.</param>
/// <returns>A new DbFunctionExpression that returns the nanosecond difference between <param name="timeValue1"> and <param name="timeValue2">.</returns>
/// <exception cref="ArgumentNullException"><paramref name="timeValue1"/> or <paramref name="timeValue2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'DiffNanoseconds' function accepts arguments with the result types of <paramref name="timeValue1"/> and <paramref name="timeValue2"/>.</exception>
public static DbFunctionExpression DiffNanoseconds(this DbExpression timeValue1, DbExpression timeValue2)
{
EntityUtil.CheckArgumentNull(timeValue1, "timeValue1");
EntityUtil.CheckArgumentNull(timeValue2, "timeValue2");
return InvokeCanonicalFunction("DiffNanoseconds", timeValue1, timeValue2);
}
#endregion
#region Math functions - Floor, Ceiling, Round, Truncate, Abs, Power
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Round' function with the
/// specified argument, which must each have a single, double or decimal result type. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value to round.</param>
/// <returns>A new DbFunctionExpression that rounds the specified argument to the nearest integer value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Round' function accepts an argument with the result type of <paramref name="value"/>.</exception>
public static DbFunctionExpression Round(this DbExpression value)
{
EntityUtil.CheckArgumentNull(value, "value");
return InvokeCanonicalFunction("Round", value);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Round' function with the
/// specified arguments, which must have a single, double or decimal, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value to round.</param>
/// <param name="digits">An expression that specifies the number of digits of precision to use when rounding.</param>
/// <returns>A new DbFunctionExpression that rounds the specified argument to the nearest integer value, with precision as specified by <paramref name="digits"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> or <paramref name="digits"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Round' function accepts arguments with the result types of <paramref name="value"/> and <paramref name="digits"/>.</exception>
public static DbFunctionExpression Round(this DbExpression value, DbExpression digits)
{
EntityUtil.CheckArgumentNull(value, "value");
EntityUtil.CheckArgumentNull(digits, "digits");
return InvokeCanonicalFunction("Round", value, digits);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Floor' function with the
/// specified argument, which must each have a single, double or decimal result type. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value.</param>
/// <returns>A new DbFunctionExpression that returns the largest integer value not greater than <paramref name="value"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Floor' function accepts an argument with the result type of <paramref name="value"/>.</exception>
public static DbFunctionExpression Floor(this DbExpression value)
{
EntityUtil.CheckArgumentNull(value, "value");
return InvokeCanonicalFunction("Floor", value);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Ceiling' function with the
/// specified argument, which must each have a single, double or decimal result type. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value.</param>
/// <returns>A new DbFunctionExpression that returns the smallest integer value not less than than <paramref name="value"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Ceiling' function accepts an argument with the result type of <paramref name="value"/>.</exception>
public static DbFunctionExpression Ceiling(this DbExpression value)
{
EntityUtil.CheckArgumentNull(value, "value");
return InvokeCanonicalFunction("Ceiling", value);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Abs' function with the
/// specified argument, which must each have a numeric result type. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value.</param>
/// <returns>A new DbFunctionExpression that returns the absolute value of <paramref name="value"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Abs' function accepts an argument with the result type of <paramref name="value"/>.</exception>
public static DbFunctionExpression Abs(this DbExpression value)
{
EntityUtil.CheckArgumentNull(value, "value");
return InvokeCanonicalFunction("Abs", value);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Truncate' function with the
/// specified arguments, which must have a single, double or decimal, and integer result types. The result
/// type of the expression is the same as the result type of <paramref name="value"/>.
/// </summary>
/// <param name="value">An expression that specifies the numeric value to truncate.</param>
/// <param name="digits">An expression that specifies the number of digits of precision to use when truncating.</param>
/// <returns>A new DbFunctionExpression that truncates the specified argument to the nearest integer value, with precision as specified by <paramref name="digits"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> <paramref name="digits"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Truncate' function accepts arguments with the result types of <paramref name="value"/> and <paramref name="digits"/>.</exception>
public static DbFunctionExpression Truncate(this DbExpression value, DbExpression digits)
{
EntityUtil.CheckArgumentNull(value, "value");
EntityUtil.CheckArgumentNull(digits, "digits");
return InvokeCanonicalFunction("Truncate", value, digits);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'Power' function with the
/// specified arguments, which must have numeric result types. The result type of the expression is
/// the same as the result type of <paramref name="baseArgument"/>.
/// </summary>
/// <param name="baseArgument">An expression that specifies the numeric value to raise to the given power.</param>
/// <param name="exponent">An expression that specifies the power to which <paramref name="baseArgument"/> should be raised.</param>
/// <returns>A new DbFunctionExpression that returns the value of <paramref name="baseArgument"/> raised to the power specified by <paramref name="exponent"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="baseArgument"/> <paramref name="exponent"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'Power' function accepts arguments with the result types of <paramref name="baseArgument"/> and <paramref name="exponent"/>.</exception>
public static DbFunctionExpression Power(this DbExpression baseArgument, DbExpression exponent)
{
EntityUtil.CheckArgumentNull(baseArgument, "baseArgument");
EntityUtil.CheckArgumentNull(exponent, "exponent");
return InvokeCanonicalFunction("Power", baseArgument, exponent);
}
#endregion
#region Bitwise functions - And, Or, Not, Xor
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'BitwiseAnd' function with the
/// specified arguments, which must have the same integer numeric result type. The result type of the
/// expression is this same type.
/// </summary>
/// <param name="value">An expression that specifies the first operand.</param>
/// <param name="value2">An expression that specifies the second operand.</param>
/// <returns>A new DbFunctionExpression that returns the value produced by performing the bitwise AND of <paramref name="value1"/> and <paramref name="value2"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value1"/> <paramref name="value2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'BitwiseAnd' function accepts arguments with the result types of <paramref name="value1"/> and <paramref name="value2"/>.</exception>
public static DbFunctionExpression BitwiseAnd(this DbExpression value1, DbExpression value2)
{
EntityUtil.CheckArgumentNull(value1, "value1");
EntityUtil.CheckArgumentNull(value2, "value2");
return InvokeCanonicalFunction("BitwiseAnd", value1, value2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'BitwiseOr' function with the
/// specified arguments, which must have the same integer numeric result type. The result type of the
/// expression is this same type.
/// </summary>
/// <param name="value1">An expression that specifies the first operand.</param>
/// <param name="value2">An expression that specifies the second operand.</param>
/// <returns>A new DbFunctionExpression that returns the value produced by performing the bitwise OR of <paramref name="value1"/> and <paramref name="value2"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value1"/> <paramref name="value2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'BitwiseOr' function accepts arguments with the result types of <paramref name="value1"/> and <paramref name="value2"/>.</exception>
public static DbFunctionExpression BitwiseOr(this DbExpression value1, DbExpression value2)
{
EntityUtil.CheckArgumentNull(value1, "value1");
EntityUtil.CheckArgumentNull(value2, "value2");
return InvokeCanonicalFunction("BitwiseOr", value1, value2);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'BitwiseNot' function with the
/// specified argument, which must have an integer numeric result type. The result type of the expression
/// is this same type.
/// </summary>
/// <param name="value">An expression that specifies the first operand.</param>
/// <returns>A new DbFunctionExpression that returns the value produced by performing the bitwise NOT of <paramref name="value"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'BitwiseNot' function accepts an argument with the result type of <paramref name="value"/>.</exception>
public static DbFunctionExpression BitwiseNot(this DbExpression value)
{
EntityUtil.CheckArgumentNull(value, "value");
return InvokeCanonicalFunction("BitwiseNot", value);
}
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'BitwiseXor' function with the
/// specified arguments, which must have the same integer numeric result type. The result type of the
/// expression is this same type.
/// </summary>
/// <param name="value1">An expression that specifies the first operand.</param>
/// <param name="value2">An expression that specifies the second operand.</param>
/// <returns>A new DbFunctionExpression that returns the value produced by performing the bitwise XOR (exclusive OR) of <paramref name="value1"/> and <paramref name="value2"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value1"/> <paramref name="value2"/> is null.</exception>
/// <exception cref="ArgumentException">No overload of the canonical 'BitwiseXor' function accepts arguments with the result types of <paramref name="value1"/> and <paramref name="value2"/>.</exception>
public static DbFunctionExpression BitwiseXor(this DbExpression value1, DbExpression value2)
{
EntityUtil.CheckArgumentNull(value1, "value1");
EntityUtil.CheckArgumentNull(value2, "value2");
return InvokeCanonicalFunction("BitwiseXor", value1, value2);
}
#endregion
#region GUID Generation - NewGuid
/// <summary>
/// Creates a <see cref="DbFunctionExpression"/> that invokes the canonical 'NewGuid' function.
/// </summary>
/// <returns>A new DbFunctionExpression that returns a new GUID value.</returns>
public static DbFunctionExpression NewGuid()
{
return InvokeCanonicalFunction("NewGuid");
}
#endregion
}
}
|