This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi I need your help because I just cannot figure out what is wrong. I executed the following code: using (CirtsDomainUnitOfWork unitOfWork = new CirtsDomainUnitOfWork()) { var testReturnCollection = unitOfWork.Carers.Select(x => x).First(); ... } and I get a NullReferenceException with the following stack trace: at Mindscape.LightSpeed.Model.TypeModel.(LightSpeedContext , Boolean ) at ..(TypeModel , Query , IList ) at ..(UnitOfWorkBase , TypeModel , Query , IList ) at ..(Query , TypeModel , IList ) at ..(Query , IList ) at Mindscape.LightSpeed.UnitOfWork.Find(Query query, IList results) at Mindscape.LightSpeed.UnitOfWorkBase.Find(Query query) at Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ExecuteImmediate(IUnitOfWork unitOfWork, Type returnType) at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.First[TSource](IQueryable`1 source) at Lwb.Cirts.Server.Services.AtAGlance.Repositories.AtAGlanceRepository.GetPlacementRecordsByClient(Guid clientId, DateTime startDate, DateTime endDate) in D:\Dev\Clients\LWB\Life Without Barriers - CIRTS\Trunk\Cirts\src\Cirts\Server\Lwb.Cirts.Server.Services\AtAGlance\Repositories\AtAGlanceRepository.cs:line 20 at Lwb.Cirts.Server.Services.AtAGlance.AtAGlanceService.GetPlacementRecordsByClient(Guid clientId, DateTime startDate, DateTime endDate) in D:\Dev\Clients\LWB\Life Without Barriers - CIRTS\Trunk\Cirts\src\Cirts\Server\Lwb.Cirts.Server.Services\AtAGlance\AtAGlanceService.svc.cs:line 131 at SyncInvokeGetPlacementRecordsByClient(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) Any ideas or am I just being stupid? JB |
|
|
You need to create the UnitOfWork by using a LightSpeedContext, you cannot "new one up" as you are doing above. e.g. Assuming your context configuration is named "Development" then you would call:
Im actually a bit surprised you get a NullReferenceException though rather than a LightSpeedException. We have a few checks for the context being null at entry points for queries so I would have expected you to hit that.
|
|
|
Hi Mate Thanks for that. I will create the unit of work as above. I am pretty new to using Lightspeed, so that explains my mistake. :-) YOUR SUPPORT ROCK!! Over and Out gssst. JB |
|