首页 > 解决方案 > 当我使用 StoredProcedureEFCore Nuget 包时出现“Size 属性的大小为 0 addparam 无效”错误

问题描述

我正在为我的 .net 核心 pwa 项目使用 StoredProcedureEFCore nuget 包。我正在尝试使用带有一些字符串输出参数的存储过程,但是当我运行它时,它会给出错误消息“Size 属性的大小为 0 无效”

我已阅读文档,但找不到字符串大小的内容: https ://github.com/verdie-g/StoredProcedureEFCore

also I have tested this: 
I test this:
bookNameParameter.Size = 500;

but it does not work for this nuget package.
C#
context.LoadStoredProc("dbo.Book_Details")
                .AddParam("BookId", bookId)
                .AddParam("Id", out IOutParam<long> id)
                .AddParam("BookName", out IOutParam<string> bookNameParameter)
                .AddParam("ProducerName", out IOutParam<string> producerNameParameter)
                .AddParam("EnBookName", out IOutParam<string> enBookNameParameter)
                .AddParam("EnProducerName", out IOutParam<string> enProducerNameParameter)
                .AddParam("Content", out IOutParam<string> contentParameter)
                .AddParam("Type", out IOutParam<int> TypeParameter)
                .AddParam("Price", out IOutParam<int> PriceParameter)
                .AddParam("DiscountPrice", out IOutParam<int> DiscountPriceParameter)
                .AddParam("LikeCount", out IOutParam<int> likeCountParameter)
                .AddParam("BaseLikeCount", out IOutParam<int> baseLikeCountParameter)
                .AddParam("BookPage", out IOutParam<int> BookPageParameter)
                .AddParam("PublisherName", out IOutParam<string> publisherNameParameter)
                .AddParam("BookSize", out IOutParam<int> BookSizeParameter)
                .AddParam("LanguageType", out IOutParam<int> LanguageTypeParameter)
                .AddParam("PresentationMode", out IOutParam<int> PresentationModeParameter)
                .AddParam("ISBN", out IOutParam<string> ISBNParameter)
                .AddParam("BookVersion", out IOutParam<long> bookVersionParameter)
                .AddParam("AverageRate", out IOutParam<float> averageRateParameter)
                .Exec(r => lstEpisode = r.ToList<Episode>());

如何为这些参数定义大小?

标签: c#sql-serverstored-proceduresentity-framework-core

解决方案


尝试设置每个IOutParam<string>这样的大小

.AddParam("BookName", out IOutParam<string> bookNameParameter,500)

推荐阅读