-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for halfvec type to EF Core
- Loading branch information
Showing
5 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping; | ||
using NpgsqlTypes; | ||
|
||
namespace Pgvector.EntityFrameworkCore; | ||
|
||
public class HalfvecTypeMapping : RelationalTypeMapping | ||
{ | ||
public static HalfvecTypeMapping Default { get; } = new(); | ||
|
||
public HalfvecTypeMapping() : base("halfvec", typeof(HalfVector)) { } | ||
|
||
public HalfvecTypeMapping(string storeType) : base(storeType, typeof(HalfVector)) { } | ||
|
||
protected HalfvecTypeMapping(RelationalTypeMappingParameters parameters) : base(parameters) { } | ||
|
||
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) | ||
=> new HalfvecTypeMapping(parameters); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Pgvector.EntityFrameworkCore/HalfvecTypeMappingSourcePlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
|
||
namespace Pgvector.EntityFrameworkCore; | ||
|
||
public class HalfvecTypeMappingSourcePlugin : IRelationalTypeMappingSourcePlugin | ||
{ | ||
public RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo) | ||
=> mappingInfo.ClrType == typeof(HalfVector) | ||
? new HalfvecTypeMapping(mappingInfo.StoreTypeName ?? "halfvec") | ||
: null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters