Создайте довольно простой запрос LINQ:
var objectExternalIds = new string[] { "abc" };
var query = from order in Context.Order
join apointment in Context.Appointment on order.Nr equals apointment.OrderNr
where objectExternalIds.Contains(order.ObjectId)
select apointment.Id;
var result = await query.ToListAsync(cancellationToken);
Это приводит к ошибке:
An exception was thrown while attempting to evaluate the LINQ query parameter expression 'op_Implicit(Convert(value(Application.Shared.DataWrappers.Order.OrderDataWrapper+c__DisplayClass23_0).objectExternalIds, String[]))'. See the inner exception for more information.
GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type 'TRet'.
GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type parameter 'TRet'.
Я использую базу данных MySql с Pomelo.EntityFrameworkCore.MySql в качестве поставщика
Я не понимаю, что эта ошибка должна быть довольно простой
РЕДАКТИРОВАТЬ:
Классы контекста:
public class Order {
public int Id { get; set; }
public string ObjectId { get; set; }
...
}
public class Appointment {
public int Id { get; set; }
public int? OrderNr { get; set; }
...
}
Схема БД:
CREATE TABLE `Order` (
`Nr` int(10) NOT NULL DEFAULT '0',
`ObjectId` varchar(50) COLLATE utf8_german2_ci DEFAULT NULL,
PRIMARY KEY (`Nr`),
...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
CREATE TABLE `Appointment` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`OrderNr` int(10) DEFAULT '0',
PRIMARY KEY (`ID`),
...
) ENGINE=InnoDB AUTO_INCREMENT=20848625 DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
Полное исключение:
System.InvalidOperationException
HResult=0x80131509
Message=An exception was thrown while attempting to evaluate the LINQ query parameter expression 'op_Implicit(Convert(value(Application.Shared.DataWrappers.Order.OrderDataWrapper+c__DisplayClass23_0).objectExternalIds, String[]))'. See the inner exception for more information.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.GetValue(Expression expression, String& parameterName)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Evaluate(Expression expression, Boolean generateParameter)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.ExtractParameters(Expression expression, Boolean clearEvaluatedValues)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.ExtractParameters(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExtractParameters(Expression query, IParameterValues parameterValues, IDiagnosticsLogger`1 logger, Boolean parameterize, Boolean generateContextAccessors)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.d__67`1.MoveNext()
at Program.d__9.MoveNext() in C:\_temp\Test\Program.cs:line 59
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
ArgumentException: GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type 'TRet'.
Inner Exception 2:
TypeLoadException: GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type parameter 'TRet'.
Подробнее здесь: https://stackoverflow.com/questions/797 ... rameter-ex
Возникло исключение при попытке оценить выражение параметра запроса LINQ. ⇐ C#
Место общения программистов C#
1768462974
Anonymous
Создайте довольно простой запрос LINQ:
var objectExternalIds = new string[] { "abc" };
var query = from order in Context.Order
join apointment in Context.Appointment on order.Nr equals apointment.OrderNr
where objectExternalIds.Contains(order.ObjectId)
select apointment.Id;
var result = await query.ToListAsync(cancellationToken);
Это приводит к ошибке:
An exception was thrown while attempting to evaluate the LINQ query parameter expression 'op_Implicit(Convert(value(Application.Shared.DataWrappers.Order.OrderDataWrapper+c__DisplayClass23_0).objectExternalIds, String[]))'. See the inner exception for more information.
GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type 'TRet'.
GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type parameter 'TRet'.
Я использую базу данных MySql с Pomelo.EntityFrameworkCore.MySql в качестве поставщика
Я не понимаю, что эта ошибка должна быть довольно простой
РЕДАКТИРОВАТЬ:
Классы контекста:
public class Order {
public int Id { get; set; }
public string ObjectId { get; set; }
...
}
public class Appointment {
public int Id { get; set; }
public int? OrderNr { get; set; }
...
}
Схема БД:
CREATE TABLE `Order` (
`Nr` int(10) NOT NULL DEFAULT '0',
`ObjectId` varchar(50) COLLATE utf8_german2_ci DEFAULT NULL,
PRIMARY KEY (`Nr`),
...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
CREATE TABLE `Appointment` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`OrderNr` int(10) DEFAULT '0',
PRIMARY KEY (`ID`),
...
) ENGINE=InnoDB AUTO_INCREMENT=20848625 DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci;
Полное исключение:
System.InvalidOperationException
HResult=0x80131509
Message=An exception was thrown while attempting to evaluate the LINQ query parameter expression 'op_Implicit(Convert(value(Application.Shared.DataWrappers.Order.OrderDataWrapper+c__DisplayClass23_0).objectExternalIds, String[]))'. See the inner exception for more information.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.GetValue(Expression expression, String& parameterName)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Evaluate(Expression expression, Boolean generateParameter)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.ExtractParameters(Expression expression, Boolean clearEvaluatedValues)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.ExtractParameters(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExtractParameters(Expression query, IParameterValues parameterValues, IDiagnosticsLogger`1 logger, Boolean parameterize, Boolean generateContextAccessors)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.d__67`1.MoveNext()
at Program.d__9.MoveNext() in C:\_temp\Test\Program.cs:line 59
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
ArgumentException: GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type 'TRet'.
Inner Exception 2:
TypeLoadException: GenericArguments[1], 'System.ReadOnlySpan`1[System.String]', on 'System.Linq.Expressions.Interpreter.FuncCallInstruction`2[T0,TRet]' violates the constraint of type parameter 'TRet'.
Подробнее здесь: [url]https://stackoverflow.com/questions/79791484/an-exception-was-thrown-while-attempting-to-evaluate-the-linq-query-parameter-ex[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия