DbExpressionBuilder.OfTypeOnly 方法
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
建立新的 DbOfTypeExpression,它會從指定輸入集,產生剛好具有指定類型的項目集。
命名空間: System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
<ExtensionAttribute> _
Public Shared Function OfTypeOnly ( _
argument As DbExpression, _
type As TypeUsage _
) As DbOfTypeExpression
'用途
Dim argument As DbExpression
Dim type As TypeUsage
Dim returnValue As DbOfTypeExpression
returnValue = argument.OfTypeOnly(type)
public static DbOfTypeExpression OfTypeOnly(
this DbExpression argument,
TypeUsage type
)
[ExtensionAttribute]
public:
static DbOfTypeExpression^ OfTypeOnly(
DbExpression^ argument,
TypeUsage^ type
)
static member OfTypeOnly :
argument:DbExpression *
type:TypeUsage -> DbOfTypeExpression
public static function OfTypeOnly(
argument : DbExpression,
type : TypeUsage
) : DbOfTypeExpression
參數
- argument
類型:System.Data.Entity.Core.Common.CommandTrees.DbExpression
指定輸入集的 DbExpression。
- type
類型:System.Data.Entity.Core.Metadata.Edm.TypeUsage
類型中繼資料,輸入集項目必須完全符合該類型,才能包含在結果集內。
傳回值
類型:System.Data.Entity.Core.Common.CommandTrees.DbOfTypeExpression
具有指定集合引數和類型以及 OfTypeOnly 之 ExpressionKind 的新 DbOfTypeExpression。
使用注意事項
在 Visual Basic 和 C# 中,您可以在任何 DbExpression 類型物件中呼叫這個方法以做為執行個體。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=vs.113)或 https://msdn.microsoft.com/zh-tw/library/bb383977(v=vs.113)。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentNullException | argument 或 type 為 null。 |
ArgumentException | argument 沒有集合結果 type,或者類型不是與 argument 集合結果類型的元素類型位於相同類型階層中的類型。 |
備註
DbOfTypeExpression 需要 argument 的集合結果類型具有多型元素類型,而且 type 的類型來自與該元素類型相同的類型階層。
請參閱
參考
System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder 命名空間