I receive the error message Unable to determine the serialization information for a => a.CurrentProcessingStep when I try to Update my document.
I'm using the Mongo .NET Driver version 2.8 and .NET Framework 4.7.2.
I'm building the filter and update statements using the builder helpers from the library.
Here is the relevant section of my document class:
[BsonIgnoreExtraElements]
[DebuggerDisplay("{Term}, Rule Status = {_ruleStatus}, Current Step = {_currentProcessingStep}")]
public class SearchTermInfo : AMongoConnectedObject
{
[BsonElement("CurrentProcessingStep")]
private ProcessingStep _currentProcessingStep;
[BsonElement("RuleStatus")]
private RuleStatus _ruleStatus;
[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
public DateTime AddDateTime { get; set; }
[BsonIgnore]
[JsonIgnore]
public ProcessingStep CurrentProcessingStep
{
get => _currentProcessingStep;
set => AddHistoryRecord(value);
}
[BsonIgnore]
[JsonIgnore]
public RuleStatus RuleStatus
{
get => _ruleStatus;
set => AddHistoryRecord(value);
}
I'm building the filter with this code:
FilterDefinition<SearchTermInfo> filter = Builders<SearchTermInfo>.Filter.And(
Builders<SearchTermInfo>.Filter.Eq(a => a.Id, recordId),
Builders<SearchTermInfo>.Filter.Or(
Builders<SearchTermInfo>.Filter.Eq(a => a.CurrentProcessingStep, currentStep),
Builders<SearchTermInfo>.Filter.Exists("CurrentProcessingStep", false)
)
);
Then I execute the update:
UpdateResult results =
searchTermInfoCollection.MongoCollection.UpdateOne(filter, update, null, cancellationToken);
and I get this error:
? ex
{"Unable to determine the serialization information for a => a.CurrentProcessingStep."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233079
HelpLink: null
InnerException: null
Message: "Unable to determine the serialization information for a => a.CurrentProcessingStep."
Source: "MongoDB.Driver"
StackTrace: " at MongoDB.Driver.ExpressionFieldDefinition`2.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry, Boolean allowScalarValueForArrayField)
at MongoDB.Driver.SimpleFilterDefinition`2.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)\r\n
at MongoDB.Driver.OrFilterDefinition`1.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)\r\n
at MongoDB.Driver.AndFilterDefinition`1.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.ConvertWriteModelToWriteRequest(WriteModel`1 model, Int32 index)\r\n
at System.Linq.Enumerable.<SelectIterator>d__5`2.MoveNext()\r\n
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation..ctor(CollectionNamespace collectionNamespace, IEnumerable`1 requests, MessageEncoderSettings messageEncoderSettings)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.CreateBulkWriteOperation(IEnumerable`1 requests, BulkWriteOptions options)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.<>c__DisplayClass23_0.<BulkWrite>b__0(IClientSessionHandle session)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)\r\n
at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)\r\n
at MongoDB.Driver.MongoCollectionBase`1.UpdateOne(FilterDefinition`1 filter, UpdateDefinition`1 update, UpdateOptions options, Func`3 bulkWrite)\r\n
at MongoDB.Driver.MongoCollectionBase`1.UpdateOne(FilterDefinition`1 filter, UpdateDefinition`1 update, UpdateOptions options, CancellationToken cancellationToken)\r\n
at SaFileIngestion.FileProcessorEngine.LockRecord(Int64 recordId, ProcessingStep currentStep, CancellationToken cancellationToken)
in D:\\[File Path]\\SaFileIngestion\\FileProcessorEngine.cs:line 195"
TargetSite: {MongoDB.Driver.RenderedFieldDefinition`1[TField] Render(MongoDB.Bson.Serialization.IBsonSerializer`1[TDocument], MongoDB.Bson.Serialization.IBsonSerializerRegistry, Boolean)}
I've also tried to build the filter with this code:
Builders<SearchTermInfo>.Filter.Eq("CurrentProcessingStep", currentStep),
It was my impression that I should be able to build an expression using the property accessor, even though it is flagged as BsonIgnore, since the private field has been attributed with BsonElementAttribute with the same name as the ignored property accessor.
Any guidance provided is appreciated.
Thanks
I eventually resolved this. I don't remember the exact solution as it was over a year ago. I do remember there was something wrong with the way the query was being constructed.
Related
I am in the process of consolidating queries to minimize the number of SQL round trips.
For results with Skip Take there seems to be a problem with the ProjectTo method of the AutoMapper.
Works:
var totalUsers = await _dbContext.UserAccounts.CountAsync(cancellationToken);
var users = await _dbContext.UserAccounts
.Skip(skip).Take(take)
.ProjectTo<UserProjection>(_mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
Throws a NullReferenceException:
// query
var query = from _ in _dbContext.UserAccounts
select new
{
TotalUserCount = _dbContext.UserAccounts.Count(),
Users = _dbContext.UserAccounts
.Skip(skip).Take(take)
.ProjectTo<UserProjection>(_mapper.ConfigurationProvider)
.ToList()
};
var result = await query.FirstOrDefaultAsync(cancellationToken);
Stack:
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression.AddCollectionProjection(ShapedQueryExpression shapedQueryExpression, INavigation navigation, Type elementType)
Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.VisitNew(NewExpression newExpression)
System.Linq.Expressions.NewExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Translate(SelectExpression selectExpression, Expression expression)
Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector)
Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor(Expression query)
Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery(Expression query, bool async)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore(IDatabase database, Expression query, IModel model, bool async)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__DisplayClass12_0.b__0()
Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore(object cacheKey, Func> compiler)
Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery(object cacheKey, Func> compiler)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync(Expression query, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync(Expression expression, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(IQueryable source, CancellationToken cancellationToken)
The problem occurs especially in combination with Skip and Take.
Any idea what could be the reason for this? Or is this a bug of AutoMapper?
The code example is taken from an ASP.NET Core 3.1 application with current AutoMapper version
I'm not finding much on this, and after spending most of the day...I'm looking for help..
The exception I get is this:
Unable to cast COM object of type 'System.__ComObject' to interface
type 'IFabricSecretStoreClient'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{38C4C723-3815-49D8-BDF2-68BFB536B8C9}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
I'm able to instantiate the proxy to the Stateful Service with this code:
var servicekey = new ServicePartitionKey(0);
var queryserviceUri = new Uri("fabric:/XXXX/xxxxxxxxxx");
var proxyHandle = ServiceProxy.Create<IAnInterfaceName>(queryserviceUri, servicekey, TargetReplicaSelector.PrimaryReplica);
Then I use the proxy:
var result = await proxyHandle.OperationOnServiceContract(dataPackage);
At this point I get the error...
Stacktrace...
at System.Fabric.FabricClient.CreateNativeClient(IEnumerable1
connectionStringsLocal) at
System.Fabric.Interop.Utility.<>c__DisplayClass27_0.<WrapNativeSyncInvoke>b__0()
at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func1
func, String functionTag, String functionArgs) at
System.Fabric.Interop.Utility.WrapNativeSyncInvoke(Action action,
String functionTag, String functionArgs) at
System.Fabric.Interop.Utility.RunInMTA(Action action) at
System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials
credentialArg, FabricClientSettings newSettings, String[]
hostEndpointsArg) at
Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.<>c.b__21_0()
at
Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.GetClient()
at
Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.ResolveHelperAsync(Func5
resolveFunc, ResolvedServicePartition previousRsp, TimeSpan
resolveTimeout, TimeSpan maxRetryInterval, CancellationToken
cancellationToken, Uri serviceUri) at
Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase1.GetClientAsync(Uri
serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector
targetReplicaSelector, String listenerName, OperationRetrySettings
retrySettings, CancellationToken cancellationToken) at
Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client.FabricTransportServiceRemotingClientFactory.GetClientAsync(Uri
serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector
targetReplicaSelector, String listenerName, OperationRetrySettings
retrySettings, CancellationToken cancellationToken) at
Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient1.GetCommunicationClientAsync(CancellationToken
cancellationToken) at
Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient1.InvokeWithRetryAsync[TResult](Func2
func, CancellationToken cancellationToken, Type[]
doNotRetryExceptionTypes) at
Microsoft.ServiceFabric.Services.Remoting.V2.Client.ServiceRemotingPartitionClient.InvokeAsync(IServiceRemotingRequestMessage
remotingRequestMessage, String methodName, CancellationToken
cancellationToken) at
Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.InvokeAsyncV2(Int32
interfaceId, Int32 methodId, String methodName,
IServiceRemotingRequestMessageBody requestMsgBodyValue,
CancellationToken cancellationToken) at
Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.ContinueWithResultV2[TRetval](Int32
interfaceId, Int32 methodId, Task1 task) at
XXXXWeb.Controllers.XXXController.OperationOnServiceContract(XXXRequest
xxxRequest) in
C:\Users\codputer\Source\Repos\xxxxxx\xxxx.Web\Controllers\XXXController.cs:line
44
oh I'm using this for a listener:
protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
return this.CreateServiceRemotingReplicaListeners();
}
As noted on these issues:
#476#Azure/service-fabric-issues
#1374#Azure/service-fabric-issues
#262#Microsoft/service-fabric
These COM issues happens whenever you use newer Nuget packages targeting older version of service fabric runtime, this kind of error occurs.
You should always use the packages targeted to the same version of your cluster runtime, on last case, use package older than the cluster version.
When I attempt to deploy DACPACs via SqlPackage.exe,
I encounter the error below :
An unexpected failure occurred: Object reference not set to an instance of an object..
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.Sql90TableBaseColumnPopulator`1.InsertElementIntoParent(SqlColumn element, TElement parent, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.ChildModelElementPopulator`2.CreateChildElement(TParent parent, EventArgs e, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.ChildModelElementPopulator`2.PopulateAllChildrenFromCache(IDictionary`2 cache, SqlReverseEngineerRequest request, OrdinalSqlDataReader reader, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.TopLevelElementPopulator`1.Populate(SqlReverseEngineerRequest request, OrdinalSqlDataReader reader, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulators(ReliableSqlConnection conn, IList`1 populators, Int32 totalPopulatorsCount, Int32 startIndex, Boolean progressAlreadyUpdated, ReverseEngineerOption option, SqlReverseEngineerRequest request)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulatorsInPass(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, SqlReverseEngineerRequest request, Int32 totalCount, Tuple`2[] populatorsArray)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.PopulateBatch(SqlReverseEngineerConnectionContext context, SqlSchemaModel model, ReverseEngineerOption option, ErrorManager errorManager, SqlReverseEngineerRequest request, SqlImportScope importScope)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineer.PopulateAll(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, ErrorManager errorManager, Boolean filterManagementScopedElements, SqlImportScope importScope, Boolean optimizeForQuery, ModelStorageType modelType)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.ImportDatabase(SqlReverseEngineerConstructor constructor, DeploymentEngineContext context, ErrorManager errorManager)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnLoad(ErrorManager errors, DeploymentEngineContext context)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.PrepareModels()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
at Microsoft.SqlServer.Dac.DacServices.<>c__DisplayClass21.<CreateDeploymentArtifactGenerationOperation>b__1f(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.GenerateDeployScript(DacPackage package, String targetDatabaseName, DacDeployOptions options, Nullable`1 cancellationToken)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.<>c__DisplayClasse.<DoDeployAction>b__4(DacServices service)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.ExecuteDeployOperation(String connectionString, String filePath, MessageWrapper messageWrapper, Boolean sourceIsPackage, Boolean targetIsPackage, Func`1 generateScriptFromPackage, Func`2 generateScriptFromDatabase)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.DoDeployAction(DeployArguments parsedArgs, Action`1 writeError, Action`2 writeMessage, Action`1 writeWarning)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.DoDeployActions(CommandLineArguments parsedArgs)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Run(String[] args)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)
Below is the command I run:
SET vardeploy2=/Action:Script
set varBlockOnDriftParameter=/p:BlockWhenDriftDetected=False
"SSDTBinaries\SqlPackage.exe" %vardeploy2% %varBlockOnDriftParameter% /SourceFile:"dacpacs\DBName.dacpac" /Profile:"Profiles\%1.DBName.Publish.xml" >> Log.txt 2>>&1
I deploy to a SQL Server 2008 R2. The SqlPackage.exe version is 11.0.2820.0.
The issue is intermittent, which suggests it's not related to the DACPAC being deployed or the destination database's schema. My best guess is that something about the state of the database is causing the problem.
Still, I haven't been able to identify anything unusual at the time of the failures.
When recreating the issue locally, using schema locks results in a different error message.
Has anyone know of a solution?
Upgrade to a more resent SQL Server Data Tools.
I am getting a NotSupportedException after I added a TimeSpan property to the Employee entity in the DocCode project. So I know it isn't supported but... Are there plans to do a conversion or a way to get past this. We use TimeSpan extensively in our entities, is there a way to support TimeSpan or plans to?
Added Duration property
public class Employee
{
...
public DateTime? HireDate { get; set; }
public TimeSpan? Duration { get; set; }
[MaxLength(60)]
public string Address { get; set; }
...
}
When the MetaData() method is called on the NorthwindController running the unit test it fails:
System.NotSupportedException was unhandled by user code
HResult=-2146233067
Message=There is no store type corresponding to the EDM type 'Edm.Time(Nullable=True)' of primitive type 'Time'.
Source=System.Data.SqlServerCe.Entity
StackTrace:
at System.Data.SqlServerCe.SqlCeProviderManifest.GetStoreType(TypeUsage edmType)
at System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.MapTableColumn(EdmProperty property, DbTableColumnMetadata tableColumnMetadata, Boolean isInstancePropertyOnDerivedType, Boolean isKeyProperty)
at System.Data.Entity.ModelConfiguration.Edm.Services.PropertyMappingGenerator.Generate(EdmEntityType entityType, IEnumerable`1 properties, DbEntitySetMapping entitySetMapping, DbEntityTypeMappingFragment entityTypeMappingFragment, IList`1 propertyPath, Boolean createNewColumn)
at System.Data.Entity.ModelConfiguration.Edm.Services.EntityTypeMappingGenerator.Generate(EdmEntityType entityType, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(EdmModel model, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel model)
at System.Data.Entity.ModelConfiguration.Edm.EdmModelExtensions.GenerateDatabaseMapping(EdmModel model, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
at Breeze.WebApi.EFContextProvider`1.GetCsdlFromObjectContext(Object context)
at Breeze.WebApi.EFContextProvider`1.GetCsdlFromDbContext(Object context)
at Breeze.WebApi.EFContextProvider`1.BuildJsonMetadata()
at Breeze.WebApi.ContextProvider.Metadata()
at DocCode.Controllers.NorthwindController.Metadata() in c:\Users\anwalker\Downloads\breeze-runtime-plus-0.78.2\Samples\DocCode\DocCode\Controllers\NorthwindController.cs:line 20
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
InnerException:
TimeSpan support was added in build 0.84.1.
TimeSpans are represented as ISO 8601 'duration' strings on the breeze client. See http://en.wikipedia.org/wiki/ISO_8601
Full query support includes the ability to both filter and return TimeSpan/Duration properties. i.e.
var query = EntityQuery.from("Contracts").where("TimeElapsed", ">", "PT4H30M");
Ok, after a little research, it makes sense to serialize a .NET timespan to the javascript client using the ISO8601 'duration' standard which would represent a timespan in days, hours, minutes, and seconds as a formatted string something like: "PnnnDTnnHnnMnn.nnnS". Obviously, you will need a javascript library on the client to interpret and work with this. Would this meet your needs?
I've added this to our feature request log, but please also add it to the Breeze User Voice (and vote for it :)). This helps us prioritize the outstanding feature requests.
Hm.. The request makes sense. But what would you want it converted to in javascript, a string or a number of seconds since a point in time or .... Is there a standard javascript representation for a .NET timespan?
I am developing a WPF Applicaton using Entity Framework for data access. As design pattern i use "MVVM" for tier organization, and "Repository" with "UnitOfWork" for data layer organization.
Generic Repository class:
public class EFRepository : IRepository where T : class
{
public IUnitOfWork UnitOfWork { get; set; }
private IObjectSet _objectset;
private IObjectSet ObjectSet
{
get
{
if (_objectset == null)
{
_objectset = UnitOfWork.Context.CreateObjectSet();
}
return _objectset;
}
}
public virtual IQueryable All()
{
return ObjectSet.AsQueryable();
}
...
Unit of work interface:
public interface IUnitOfWork: IDisposable
{
ObjectContext Context { get; set; }
void Save();
bool LazyLoadingEnabled { get; set; }
bool ProxyCreationEnabled { get; set; }
string ConnectionString { get; set; }
}
I build all L2E queries in model layer, like:
this.repository1.All().First(i => i.Field1 == some_value);
Sometimes here is thrown an EntityCommandExecutionException. It happens sometimes, but not regular. There is no rule to make this exception occur.
Exception Detail:
EntityCommandExecutionException:
{"An error occurred while executing the command definition. See the inner exception for details."}
InnerException:
{"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."}
StackTrace:
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at System.Data.Objects.ELinq.ObjectQueryProvider.b__0[TResult](IEnumerable`1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.First[TSource](IQueryable`1 source, Expression`1 predicate)
Please, help me to find out the problem, i really don`t know what to do now =(
p.s.:
I tried to provoke this error building and executing L2E queries in simple Console Application. I tried single L2E queries and through 1000-iterations cycles. But nothing caused this exception.
I can post any additional information if needed.
[23.03.2011]
Additional Info:
Entity Framework 4.0
MSSQL Server 2008
this exception can be thrown any time the query take place. It can be l2e query to small table (<200 rows) or large (>500k rows). Also this exception can be caused by Function Import call
when this exception is thrown,
{"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."}
it is thrown immediately, but the connection timeout is set to 30 seconds! (i think that is "key feature")
DB Server is situated in LAN, and there is no heavy traffic on DB.
as i have found out, this exception can occur any time no matter what kind of queries or tables are used.
I dont use transaction. This error occur even if i use only select queries.
I think the problem caused by using WPF with EF, because my "EF part" works fine in Console Application.
The ObjectContext has two timeout parameters:
int x = myObjectContext.Connection.ConnectionTimeout;
and
int? x = myObjectContext.CommandTimeout;
Looking at the exception and callstack I don't think that the ConnectionTimeout is the problem (that's the maximum time to try to establish a connection from the client to SQL Server). You could try to set the CommandTimeout to some high value (that's the timeout for queries and commits with SaveChanges; the value null means that the default of the underlying provider will be taken).