Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Unassigned: System.ArgumentException [1428]

$
0
0
Code First Development
Entity Framework 5.0; .NET Framework 4.0.30319.1 full; Windows server 2008 R2 Enterprice x64.

'DocumentDescription' is model. Work fine on developer machine , but on server code thows error.
```
IQueryable<UnloadDocument> query;
if (userInfo.IsShiftManager)
{
query = from unloadDocument in context.UnloadDocuments
where unloadDocument.IsConfirmed == null
select unloadDocument;
}
else
{
query = from u in context.Users
from unloadDocument in u.UnloadWarehouseDocuments
where u.UserId == userInfo.UserId && unloadDocument.IsConfirmed == null
select unloadDocument;
}

var documents = query.Select(unloadDocument =>
new DocumentDescription
{
DocumentId = unloadDocument.Id,
Context = unloadDocument.Referrer,
Comment = unloadDocument.Document.Comment,
CreatedAt = unloadDocument.Document.CreatedAt,
DocumentName = unloadDocument.Document.DocumentName,
PoolType = (int) DocumentType,
UserOpenId = unloadDocument.Document.UserOpenId,
RowVersion = unloadDocument.Document.RowVersion,
DocumentState =
unloadDocument.IsConfirmed == null
? DocumentState.AwaitingConfirmation
: DocumentState.AwaitingDisposal,
TotalCountPositions =
unloadDocument.ChangeHistory.Select(x => x.DocumentItem).
GroupBy(x => x.ItemId, k => k.Count).
Sum(x => x.Sum()),
TotalCount =
unloadDocument.ChangeHistory.GroupBy(x => x.DocumentItemId).
Count(),
CountForApprove = (from history in unloadDocument.ChangeHistory
from grouping in
unloadDocument.ChangeHistory.GroupBy(
x => x.DocumentItemId, k => k)
where
grouping.Max(m => m.ChangeTypeVal) <= Max &&
history.DocumentItemId == grouping.Key
select grouping).Count()
}).Where(x => x.CountForApprove > 0).ToList();
```

```
System.Data.Entity
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.ValidateConstant(TypeUsage constantType, Object value)
at System.Data.Objects.ELinq.ExpressionConverter.ConstantTranslator.TypedTranslate(ExpressionConverter parent, ConstantExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
at System.Data.Objects.ELinq.ExpressionConverter.ConditionalTranslator.TypedTranslate(ExpressionConverter parent, ConditionalExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
at System.Data.Objects.ELinq.ExpressionConverter.MemberInitTranslator.TypedTranslate(ExpressionConverter parent, MemberInitExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding& binding)
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda)
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Handal.Documenting.Warehouse.Service.UnloadWorker.EnumerateDocuments(String authToken, Int32 pagestart, Int32 pagesize)
```
Comments: 4.0.30319.1 indicates .NET Framework 4. Enums are not supported on .NET Framework 4 if you are using EF4 or EF5. You would either have to use EF6 (it supports enums on .NET Framework 4) or update the server to use .NET Framework 4.5 or convert enum typed properties in your model to properties of the underlying enum type.

Viewing all articles
Browse latest Browse all 10318

Trending Articles