@@ -19,10 +19,27 @@ type RecordTemplate<'TRecord> internal () =
1919 let pickler = Pickler.resolve< 'TRecord>() :?> RecordPickler< 'TRecord>
2020 let keyStructure = KeyStructure.FromRecordInfo pickler.RecordInfo
2121 let keySchema = TableKeySchema.OfKeyStructure keyStructure
22+ let hkeyCond = KeyStructure.TryExtractHashKeyCondition< 'TRecord> keyStructure keySchema
2223
2324 /// Key schema used by the current record
2425 member __.KeySchema = keySchema
2526
27+ /// Gets the constant HashKey if specified by the record implementation
28+ member __.ConstantHashKey : obj option =
29+ match keyStructure with
30+ | DefaultHashKey(_, value, _, _) -> Some value
31+ | _ -> None
32+
33+ /// Gets the constant RangeKey if specified by the record implementation
34+ member __.ConstantRangeKey : obj option =
35+ match keyStructure with
36+ | DefaultRangeKey(_, value, _, _) -> Some value
37+ | _ -> None
38+
39+ /// Gets a condition expression that matches the constant HashKey,
40+ /// if so specified.
41+ member __.ConstantHashKeyCondition = hkeyCond
42+
2643 /// Record property info
2744 member internal __.Info = pickler.RecordInfo
2845
@@ -211,17 +228,6 @@ type RecordTemplate<'TRecord> internal () =
211228 /// Constructs a record instance from attribute values
212229 member internal __.OfAttributeValues ( ro : RestObject ) = pickler.ToRecord ro
213230
214- /// <summary >
215- /// Generates a HashKey equality condition used for queries
216- /// that match given table key. Useful for generating query
217- /// conditions in records that specify a ConstantHashKey attribute.
218- /// </summary >
219- /// <param name =" key " >Key that specifies the required HashKey.</param >
220- member __.GetHashKeyCondition ( key : TableKey ) =
221- let av = __. ToAttributeValues( key).[ keySchema.HashKey.AttributeName]
222- let cond = mkHashKeyEqualityCondition keySchema av
223- new ConditionExpression< 'TRecord>( cond)
224-
225231/// Record template factory methods
226232[<Sealed; AbstractClass>]
227233type RecordTemplate private () =
0 commit comments