- Home
- LLBLGen Pro
- Bugs & Issues
MySQL - Exception "The DataRowVersion enumeration value, Current, is invalid"
Joined: 19-Oct-2017
This query works on .Net 4.5.2, but it throws an Exception with .NetStandard 2.0: "[i]InvalidOperationException: The DataRowVersion enumeration value, Current, is invalid.[/i]"
In Devart's dbMonitor I see the query is not sent to the MySQL server.
var metaData = new LinqMetaData(da);
var result = from tc in metaData.TournamentCalendar
where tc.ApprovedOn != null && tc.DeletedOn == null &&
tc.DateFrom > DateTime.Today.Date
select tc;
tournaments.AddRange(res);
When omitting the WHERE clause all data is returned as expected.
Versions: * MySQL Server: 5.6.13 Windows * Devart.Data.MySql (8.9.980) * SD.LLBLGen.Pro.DQE.MySql (5.3.1-hotfix-20171018 ) * SD.LLBLGen.Pro.ORMSupportClasses (5.3.1-hotfix-20171018 )
************ Stack Trace ************
InvalidOperationException: The DataRowVersion enumeration value, Current, is invalid.
Devart.Common.DbParameterBase.set_SourceVersion(DataRowVersion value)
Devart.Data.MySql.MySqlParameter.System.Data.IDataParameter.set_SourceVersion(DataRowVersion value)
SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.CreateParameter(string parameterType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, object value)
SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.CreateParameter(IEntityFieldCore field, IFieldPersistenceInfo persistenceInfo, ParameterDirection direction, object valueToSet)
SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(bool inHavingClause)
SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(bool inHavingClause)
SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(bool inHavingClause)
SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(bool inHavingClause)
SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText()
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.AppendWhereClause(IPredicate filter, QueryFragments destination, IQuery query)
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IRetrievalQuery query, IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause, bool relationsSpecified, bool sortClausesSpecified)
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, DbConnection connectionToUse, IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause)
SD.LLBLGen.Pro.DQE.MySql.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, DbConnection connectionToUse, IPredicate selectFilter, int rowsToSkip, int rowsToTake, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause)
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, DbConnection connectionToUse, IPredicate selectFilter, int rowsToSkip, int rowsToTake, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.CreateSelectDQ(QueryParameters parameters)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntityCollectionInternal(QueryParameters parameters)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchEntityCollection(QueryParameters parameters)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.<>n__9(QueryParameters parameters)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase+<>c__DisplayClass10_0.<FetchEntityCollection>b__0()
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteWithActiveRecoveryStrategy(Action toExecute)
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(QueryParameters parameters)
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression, Type typeForPostProcessing)
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.PerformExecute(Expression expression, Type resultType)
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery.Execute()
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore.AddRange(IEnumerable<T> c)
TournamentCalendar.Data.TournamentCalendarRepository.GetActiveTournaments(EntityCollection<TournamentCalendarEntity> tournaments, IRelationPredicateBucket filter, out bool isFiltered) in TournamentCalendarRepository.cs
tournaments.AddRange(res);
TournamentCalendar.Data.TournamentCalendarRepository.GetActiveTournaments(EntityCollection<TournamentCalendarEntity> tournaments) in TournamentCalendarRepository.cs
GetActiveTournaments(tournaments, new RelationPredicateBucket(), out isFiltered);
TournamentCalendar.Models.TournamentCalendar.BrowseModel..ctor() in BrowseModel.cs
TournamentCalendarRepository.GetActiveTournaments(_tournaments);
TournamentCalendar.Controllers.TournamentCalendarController.Index() in TournamentCalendarController.cs
return View(ViewName.TournamentCalendar.Overview, new BrowseModel());
lambda_method(Closure , object , Object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, Object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeActionMethodAsync>d__12.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeNextActionFilterAsync>d__10.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeInnerFilterAsync>d__14.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeNextResourceFilter>d__22.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeFilterPipelineAsync>d__17.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeAsync>d__15.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Builder.RouterMiddleware+<Invoke>d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Session.SessionMiddleware+<Invoke>d__9.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Session.SessionMiddleware+<Invoke>d__9.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()
Joined: 19-Oct-2017
Yes - they're telling me this might be an issue with LLBLGen Pro I could reproduce this behavior with any query containing a "where". Unfortunately this also means that FetchEntity etc. do not work as well. Crash always happens after "Method Enter: CreateSelectDQ".
Using DevArt directly works with a NetCore 2.0 app:
var mySqlConn = new MySqlConnection("the-conn-string");
mySqlConn.Open();
MySqlCommand command = mySqlConn.CreateCommand();
command.CommandText = "select * from tournament_calendar where DateFrom > '2017-01-01'";
using (var reader = command.ExecuteReader())
{
for (var i = 0; i < reader.FieldCount; i++)
Console.Write(reader.GetName(i) + "\t");
Console.Write(Environment.NewLine);
while (reader.Read())
{
// printing the table content
for (var i = 0; i < reader.FieldCount; i++)
Console.Write(reader.GetValue(i) + "\t");
Console.Write(Environment.NewLine);
}
}
Btw. also no problems with
var result = da.FetchQuery<TournamentCalendarEntity>("select * from tournament_calendar where DateFrom > @DateFrom", new {DateFrom = "2017-01-01"}
and also with Dapper 1.50.2.:
var result = conn.Query<TournamentCalendarEntity>("select * from tournament_calendar where DateFrom > '2017-01-01'");
Were there no issues during your tests with mySql?
Joined: 17-Aug-2003
We do this:
/// <summary>
/// Creates a new, filled parameter.
/// </summary>
/// <param name="parameterType">Type of the parameter.</param>
/// <param name="size">The size.</param>
/// <param name="direction">The direction.</param>
/// <param name="isNullable">if set to <c>true</c> [is nullable].</param>
/// <param name="precision">The precision.</param>
/// <param name="scale">The scale.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public virtual DbParameter CreateParameter(string parameterType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, object value)
{
DbParameter toReturn = CreateParameterInstance(parameterType);
toReturn.Size = size;
toReturn.Direction = direction;
toReturn.IsNullable = isNullable;
((IDbDataParameter)toReturn).Precision = precision;
((IDbDataParameter)toReturn).Scale = scale;
toReturn.SourceColumn = string.Empty;
((IDataParameter)toReturn).SourceVersion = DataRowVersion.Current;
toReturn.Value = GetValueToSet(value);
AddParameterToScopeTracker(toReturn);
return toReturn;
}
This is normal code which works on all platforms. The DataRowVersion.Current is set to be complete. It's .NET Standard 2.0 compliant code, but I think the MySQL provider from DevArt for .NET Standard 2.0 doesn't support this as it was related to datatables, which weren't present in .NET Core 1.x. (however the property was there in .net core 1.x)
We can exclude setting this on .net standard (doesn't have much effect I think), but I also think it's DevArt's problem that they don't support a .NET Standard 2.0 property, namely IDataParameter.SourceVersion (https://apisof.net/catalog/System.Data.IDataParameter.SourceVersion )
Now, knowing their speed with changing things, it might be best for you that we simply work around this so you can proceed with your work as waiting for DevArt to fix an issue can take a long time.
Let me know what you want us to do: wait for devart to change this, or have us implement a workaround.
Joined: 19-Oct-2017
Ah, that's where the exception comes from, thanks. I confirm that
var para = new MySqlParameter() {SourceVersion = DataRowVersion.Current};
leads to this exception.
DevArt say that .NET Standard 2.0 will be supported in 1-2 months. On their website they don't mention this missing piece unfortunately. So I'll be stuck in case you guys wouldn't find a workaround - which I would highly appreciate ;-)
Joined: 17-Aug-2003
axuno wrote:
Ah, that's where the exception comes from, thanks. I confirm that
var para = new MySqlParameter() {SourceVersion = DataRowVersion.Current};
leads to this exception.
DevArt say that .NET Standard 2.0 will be supported in 1-2 months. On their website they don't mention this missing piece unfortunately.
Figured as much... This property is in .net core 1.0... oh well.
So I'll be stuck in case you guys wouldn't find a workaround - which I would highly appreciate ;-)
We'll write the workaround, run our tests and if everything is OK, we'll release a new hotfix build today. Stay tuned
(edit) https://msdn.microsoft.com/en-us/library/system.data.common.dbparameter.sourceversion(v=vs.110).aspx says 'Current' is the default, so it's of no use to set it again to ... 'current'. Line removed.
Joined: 19-Oct-2017
Perfect, all tests in my project run fine now. Thanks a lot, that's what I call really quick
Earlier today DevArt confirmed the missing support for IDataParameter.SourceVersion in the current release and they announced it will be included in the upcoming release for .Net Standard 2.0
Joined: 17-Aug-2003
axuno wrote:
Perfect, all tests in my project run fine now. Thanks a lot, that's what I call really quick
Earlier today DevArt confirmed the missing support for IDataParameter.SourceVersion in the current release and they announced it will be included in the upcoming release for .Net Standard 2.0
Good to hear everything works out fine!