diff --git a/dotnet/src/dotnetcore/GxClasses/Domain/GxEmbedding.cs b/dotnet/src/dotnetcore/GxClasses/Domain/GxEmbedding.cs index 207c0e622..e5ad3efda 100644 --- a/dotnet/src/dotnetcore/GxClasses/Domain/GxEmbedding.cs +++ b/dotnet/src/dotnetcore/GxClasses/Domain/GxEmbedding.cs @@ -10,7 +10,6 @@ namespace GeneXus.Utils { public class GxEmbedding { - public static readonly GxEmbedding Empty = new GxEmbedding() { Model=string.Empty, Dimensions=0}; ReadOnlyMemory _embedding; public GxEmbedding() @@ -20,6 +19,7 @@ public GxEmbedding(string model, int dimensions) { Model = model; Dimensions = dimensions; + _embedding = new ReadOnlyMemory(new float[dimensions]); } internal GxEmbedding(IReadOnlyList embedding) { @@ -30,6 +30,10 @@ internal GxEmbedding(float[] embedding) _embedding = embedding; } + internal static GxEmbedding Empty(string model, int dimensions) + { + return new GxEmbedding(model, dimensions); + } public override string ToString() { return $"[{string.Join(",", _embedding.Span.ToArray())}]"; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMemory.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMemory.cs index 5ac71ea95..f8e867b9e 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMemory.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMemory.cs @@ -862,10 +862,7 @@ public static object GetCopyFrom(object value) else { Type type = value.GetType(); - - if (type.IsSubclassOf(typeof(ValueType))) - return value; - else if (type == typeof(string)) + if (type.IsSubclassOf(typeof(ValueType)) || type == typeof(string)) return value; else if (type == typeof(Stream)) { @@ -874,6 +871,16 @@ public static object GetCopyFrom(object value) oStream.CopyTo(memStream); return memStream; } +#if NETCORE + else if (type == typeof(Pgvector.Vector)) + { + Pgvector.Vector vector = (Pgvector.Vector)value; + float[] copyArray = new float[vector.Memory.Length]; + vector.Memory.Span.CopyTo(copyArray); + Pgvector.Vector copyVector = new Pgvector.Vector(new ReadOnlyMemory(copyArray)); + return copyVector; + } +#endif else { byte[] valueByte = value as byte[]; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs index bf157b712..aa294798d 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs @@ -453,7 +453,7 @@ public override IGeographicNative GetGeospatial(IGxDbCommand cmd, IDataRecord DR public override GxEmbedding GetEmbedding(IGxDbCommand cmd, IDataReader DR, int i, string model, int dimensions) { if (!cmd.HasMoreRows || DR == null || DR.IsDBNull(i)) - return GxEmbedding.Empty; + return GxEmbedding.Empty(model, dimensions); else { Pgvector.Vector vector = (Pgvector.Vector)DR.GetValue(i);