36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System;
|
|
using Sample.SqlServerShardingTable.Entities;
|
|
using ShardingCore.Core.EntityMetadatas;
|
|
using ShardingCore.VirtualRoutes.Months;
|
|
|
|
namespace Sample.SqlServerShardingTable.VirtualRoutes
|
|
{
|
|
public class OrderVirtualTableRoute:AbstractSimpleShardingMonthKeyDateTimeVirtualTableRoute<Order>
|
|
{
|
|
/// <summary>
|
|
/// fix value don't use DateTime.Now because if if application restart this value where change
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override DateTime GetBeginTime()
|
|
{
|
|
return new DateTime(2021, 1, 1);
|
|
}
|
|
/// <summary>
|
|
/// configure sharding property
|
|
/// </summary>
|
|
/// <param name="builder"></param>
|
|
public override void Configure(EntityMetadataTableBuilder<Order> builder)
|
|
{
|
|
builder.ShardingProperty(o => o.CreationTime);
|
|
}
|
|
/// <summary>
|
|
/// enable auto create table job
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override bool AutoCreateTableByTime()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|