Skip to content

Commit

Permalink
Update entity-attribute.md
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 authored Sep 24, 2024
1 parent 4dd9204 commit 1c40771
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/guide/entity-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,19 @@ class JsonPocoTypeHandler : TypeHandler<JsonPoco>
{
public override object Serialize(JsonPoco value) => JsonConvert.SerializeObject(value);
public override JsonPoco Deserialize(object value) => JsonConvert.DeserializeObject<JsonPoco>((string)value);
public override void FluentApi(FluentColumn col) => col.MapType(typeof(string)).StringLength(-1);
public override void FluentApi(ColumnFluent col) => col.MapType(typeof(string)).StringLength(-1);
}
class DateOnlyTypeHandler : TypeHandler<DateOnly>
{
public override object Serialize(DateOnly value) => value.ToString("yyyy-MM-dd");
public override DateOnly Deserialize(object value) => DateOnly.TryParse(string.Concat(value), out var trydo) ? trydo : DateOnly.MinValue;
public override void FluentApi(FluentColumn col) => col.MapType(typeof(string)).StringLength(12);
public override void FluentApi(ColumnFluent col) => col.MapType(typeof(string)).StringLength(12);
}
class DateTimeOffsetTypeHandler : TypeHandler<DateTimeOffset>
{
public override object Serialize(DateTimeOffset value) => value.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
public override DateTimeOffset Deserialize(object value) => DateTimeOffset.TryParse((string)value, out var dts) ? dts : DateTimeOffset.MinValue;
public override void FluentApi(FluentColumn col) => col.MapType(typeof(string)).DbType("datetime");
public override void FluentApi(ColumnFluent col) => col.MapType(typeof(string)).DbType("datetime");
}
```

Expand Down

0 comments on commit 1c40771

Please sign in to comment.