- 1.0.5 2026-03-18 Se comprueba el atributo MaxLength en ObtieneLongitudCampo en caso de que no se encuentre la propiedad

This commit is contained in:
2026-03-18 14:53:27 +01:00
parent 10e1a15143
commit 28bd4d7345
2 changed files with 20 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
Imports System.Reflection
Imports System.ComponentModel.DataAnnotations
Imports System.Linq.Dynamic.Core
Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports Microsoft.EntityFrameworkCore
Imports Microsoft.EntityFrameworkCore.Internal
Imports System.Linq.Dynamic.Core
Namespace Extensiones
@@ -33,7 +34,21 @@ Namespace Extensiones
If Tabla Is Nothing Then Throw New Exception("Tabla " & NombreTablaBase & " no encontrada")
Dim Campo = Tabla.FindProperty(NombreCampo)
If Campo Is Nothing Then
Return -1 ' Throw New Exception("No existe el campo " & NombreCampo & " en la tabla " & NombreTablaBase)
Dim tipo = AppDomain.CurrentDomain.GetAssemblies().SelectMany(Function(a) a.GetTypes()).FirstOrDefault(Function(t) t.FullName = EspacioNombres & "." + NombreTablaBase)
If tipo IsNot Nothing Then
Dim propiedad = tipo.GetProperty(NombreCampo)
Dim maxLengthAttr = propiedad?.GetCustomAttribute(Of MaxLengthAttribute)()
If maxLengthAttr IsNot Nothing Then
Dim max As Integer = maxLengthAttr.Length
Return max
Else
Return -1
End If
Else
Return -1
End If
Else
Dim LongitudCampo As Integer? = Campo.GetMaxLength()

View File

@@ -11,11 +11,12 @@
<TargetFramework>net8.0</TargetFramework>
<PackageId>tsEFCore8</PackageId>
<PackageTags>net8.0, libreria</PackageTags>
<Version>1.0.3</Version>
<Version>1.0.5</Version>
<Authors>Pedro</Authors>
<Company>Tecnosis S.A</Company>
<Description>Utilidades Entity Framework compatibles con EF Core 8.</Description>
<PackageReleaseNotes>
- 1.0.5 2026-03-18 Se comprueba el atributo MaxLength en ObtieneLongitudCampo en caso de que no se encuentre la propiedad
- Se agrega README.md
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>