Skip to content

FreeSql.Extensions.LazyLoading 项目self-contained发布时,运行报错 #2215

@wm5370

Description

@wm5370
System.Exception: FreeSql: FluentBlazorApp.Components.Pages.Counter.Tag Compilation error: Exception has been thrown by the target of an invocation.
  using System;
  using FreeSql.DataAnnotations;
  using System.Collections.Generic;
  using System.Linq;
  
  public class FreeSqlLazyEntity__FluentBlazorApp_Components_Pages_Counter_Tag : FluentBlazorApp.Components.Pages.Counter.Tag {
    private IFreeSql __fsql_orm__ { get; set; }
  
    private bool __lazy__Parent = false;
    public  override FluentBlazorApp.Components.Pages.Counter.Tag Parent {
             get {
                    if (base.Parent == null && __lazy__Parent == false) {
                            var loc3 = __fsql_orm__.Select<FluentBlazorApp.Components.Pages.Counter.Tag>().Where(a => a.Id == this.Parent_id).ToOne();
                            base.Parent = loc3;
                            __lazy__Parent = true;
                    }
                    return base.Parent;
            }
             set {
                    base.Parent = value;
                    if (value != null) __lazy__Parent = true;
            }
    }
  }
  
     at FreeSql.Internal.Utils.GetTableByEntity(Type entity, CommonUtils common)
     at FreeSql.Internal.Utils.AddTableRef(CommonUtils common, TableInfo trytb, PropertyInfo pnv, Boolean isLazy, NativeTuple`5 vp, StringBuilder cscode)
     at FreeSql.Internal.Utils.GetTableByEntity(Type entity, CommonUtils common)
     at FreeSql.Internal.CommonUtils.GetTableByEntity(Type entity)
     at FreeSql.Internal.CommonProvider.InsertProvider`1..ctor(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
     at FreeSql.Duckdb.Curd.DuckdbInsert`1..ctor(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
     at FreeSql.Duckdb.DuckdbProvider`1.CreateInsertProvider[T1]()
     at FreeSql.Internal.CommonProvider.BaseDbProvider.Insert[T1]()
     at FreeSql.Internal.CommonProvider.BaseDbProvider.Insert[T1](T1 source)
     at FluentBlazorApp.Components.Pages.Counter..cctor() in C:\Users\wm537\source\repos\FluentBlazorApp\FluentBlazorApp\Components\Pages\Counter.razor:line 41
     --- End of inner exception stack trace ---
     at lambda_method118(Closure, IServiceProvider, Object[])
     at Microsoft.AspNetCore.Components.DefaultComponentActivator.CreateInstance(Type componentType)
     at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.ResolveComponentForRenderMode(Type componentType, Nullable`1 parentComponentId, IComponentActivator componentActivator, IComponentRenderMode renderMode)
     at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
     at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
     at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
     at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
     at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
     at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
     at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
  --- End of stack trace from previous location ---
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
     at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
     at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
     at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
     at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters)
     at Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.BeginRenderingComponent(IComponent component, ParameterView initialParameters)
     at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.RenderEndpointComponent(HttpContext httpContext, Type rootComponentType, ParameterView parameters, Boolean waitForQuiescence)
     at Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context)
     at Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context)
     at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<<InvokeAsync>b__10_0>d.MoveNext()
  --- End of stack trace from previous location ---
     at Microsoft.AspNetCore.Builder.ServerRazorComponentsEndpointConventionBuilderExtensions.<>c__DisplayClass1_1.<<AddInteractiveServerRenderMode>b__1>d.MoveNext()
  --- End of stack trace from previous location ---
     at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
     at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

应该是CS-Script.Core库引起的,该库比较旧,是否考虑换成 CS-Script 版本

	public class Song
	{
		[Column(IsIdentity = true)] public long Id { get; set; }
		public string Title { get; set; }
		public string Url { get; set; }
		public DateTime CreateTime { get; set; }
  
		[Navigate(bind: nameof(Tag.Parent_id))] public virtual ICollection<Tag> Tags { get; set; }
	}
	public class Tag
	{
		[Column(IsIdentity = true)] public long Id { get; set; }
		public string Name { get; set; }
  
		public long? Parent_id { get; set; }
		[Navigate(bind: nameof(Tag.Parent_id))] public virtual Tag Parent { get; set; }
  	}
	//初始化
	IFreeSql fsql = new FreeSql.FreeSqlBuilder()
	.UseConnectionString(FreeSql.DataType.DuckDB, @"Data Source=:memory:")
	.UseAutoSyncStructure(true).UseLazyLoading(true) //automatically synchronize the entity structure to the database
	.Build(); //be sure to define as singleton mode
	fsql.UseJsonMap();
	var item = new Song { Title = "testaddsublist" };
	item.Id = fsql.Insert(item).ExecuteIdentity();
	item.Tags = new[] {
			new Tag { Parent_id = item.Id, Name = "sub1" },
			new Tag { Parent_id = item.Id, Name = "sub2" }
		};
	fsql.Insert<Tag>(item.Tags).ExecuteAffrows();
	//查询
	Value = fsql.Select<Song>().ToList(); //该行在Windows环境执行正常,Linux上报错。

数据库版本

FreeSql.Provider.Duckdb 3.5.307

安装的Nuget包

FreeSql 3.5.307
FreeSql.Extensions.LazyLoading 3.5.307
FreeSql.Provider.Duckdb 3.5.307

.net framework/. net core? 及具体版本

.net10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions