本文整理汇总了C#中ObjectRelationalMapper.GetPersistentIdStrategy方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectRelationalMapper.GetPersistentIdStrategy方法的具体用法?C# ObjectRelationalMapper.GetPersistentIdStrategy怎么用?C# ObjectRelationalMapper.GetPersistentIdStrategy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRelationalMapper
的用法示例。
在下文中一共展示了ObjectRelationalMapper.GetPersistentIdStrategy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenExplicitIdentityForSpecificClassThenApplyOnlyInThatClassOnly
public void WhenExplicitIdentityForSpecificClassThenApplyOnlyInThatClassOnly()
{
var customPoidPattern = new Mock<IPatternValueGetter<MemberInfo, IPersistentIdStrategy>>();
var identityResult = new Mock<IPersistentIdStrategy>();
identityResult.Setup(r => r.Strategy).Returns(PoIdStrategy.Identity);
var specificId = typeof(AnotherWithInt).GetProperty("Id");
customPoidPattern.Setup(p => p.Match(It.Is<MemberInfo>(mi => mi == specificId))).Returns(true);
customPoidPattern.Setup(p => p.Get(It.Is<MemberInfo>(mi => mi == specificId))).Returns(identityResult.Object);
var orm = new ObjectRelationalMapper();
orm.Patterns.PoidStrategies.Add(customPoidPattern.Object);
orm.GetPersistentIdStrategy(typeof(EntityInt).GetProperty("Id")).Strategy.Should().Be.EqualTo(PoIdStrategy.HighLow);
orm.GetPersistentIdStrategy(specificId).Strategy.Should().Be.EqualTo(PoIdStrategy.Identity);
}
示例2: WhenIntPoidThenApplyHilo
public void WhenIntPoidThenApplyHilo()
{
var orm = new ObjectRelationalMapper();
orm.GetPersistentIdStrategy(typeof (EntityInt).GetProperty("Id")).Strategy.Should().Be.EqualTo(PoIdStrategy.HighLow);
}
示例3: WhenIntPoidExplicitSequenceThenApplySequence
public void WhenIntPoidExplicitSequenceThenApplySequence()
{
var orm = new ObjectRelationalMapper();
orm.Patterns.PoidStrategies.Add(new SequencePoidPattern());
orm.GetPersistentIdStrategy(typeof(EntityInt).GetProperty("Id")).Strategy.Should().Be.EqualTo(PoIdStrategy.Sequence);
}
示例4: WhenGuidPoidThenApplyGuidOptimized
public void WhenGuidPoidThenApplyGuidOptimized()
{
var orm = new ObjectRelationalMapper();
orm.GetPersistentIdStrategy(typeof(EntityGuid).GetProperty("Id")).Strategy.Should().Be.EqualTo(PoIdStrategy.GuidOptimized);
}
示例5: WhenGuidPoidExplicitGuidThenApplyGuid
public void WhenGuidPoidExplicitGuidThenApplyGuid()
{
var orm = new ObjectRelationalMapper();
orm.Patterns.PoidStrategies.Add(new GuidPoidPattern());
orm.GetPersistentIdStrategy(typeof(EntityGuid).GetProperty("Id")).Strategy.Should().Be.EqualTo(PoIdStrategy.Guid);
}