次の方法で共有


DbFunctions.DiffHours メソッド (Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

[このページは、Entity Framework 6 に関するページです。最新バージョンは、'Entity Framework' NuGet パッケージとして入手できます。Entity Framework の詳細については、msdn.com/data/ef を参照してください。]

LINQ to Entities クエリの一部として使用された場合、このメソッドは、2 つの日付/時刻の間の時間数を計算する DiffHours EDM 正規関数を呼び出します。

名前空間:  System.Data.Entity
アセンブリ:  EntityFramework (EntityFramework.dll 内)

構文

'宣言
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "timeValue1")> _
<DbFunctionAttribute("Edm", "DiffHours")> _
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "timeValue2")> _
Public Shared Function DiffHours ( _
    timeValue1 As Nullable(Of DateTimeOffset), _
    timeValue2 As Nullable(Of DateTimeOffset) _
) As Nullable(Of Integer)
'使用
Dim timeValue1 As Nullable(Of DateTimeOffset)
Dim timeValue2 As Nullable(Of DateTimeOffset)
Dim returnValue As Nullable(Of Integer)

returnValue = DbFunctions.DiffHours(timeValue1, _
    timeValue2)
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue1")]
[DbFunctionAttribute("Edm", "DiffHours")]
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue2")]
public static Nullable<int> DiffHours(
    Nullable<DateTimeOffset> timeValue1,
    Nullable<DateTimeOffset> timeValue2
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"timeValue1")]
[DbFunctionAttribute(L"Edm", L"DiffHours")]
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"timeValue2")]
public:
static Nullable<int> DiffHours(
    Nullable<DateTimeOffset> timeValue1, 
    Nullable<DateTimeOffset> timeValue2
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue1")>]
[<DbFunctionAttribute("Edm", "DiffHours")>]
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue2")>]
static member DiffHours : 
        timeValue1:Nullable<DateTimeOffset> * 
        timeValue2:Nullable<DateTimeOffset> -> Nullable<int> 
public static function DiffHours(
    timeValue1 : Nullable<DateTimeOffset>, 
    timeValue2 : Nullable<DateTimeOffset>
) : Nullable<int>

パラメーター

戻り値

型 : System.Nullable<Int32>
最初と 2 番目の日付/時刻の間の時間数。

解説

この関数を直接呼び出すことはできません。 この関数は、LINQ to Entities クエリ内でのみ使用できます。 この関数は、データベース内の対応する関数に変換されます。

参照

参照

DbFunctions クラス

DiffHours オーバーロード

System.Data.Entity 名前空間