You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I execute the code below, it generates an exception. Where am I going wrong?
Code that generates exception specifically extractor.Extract:
publicVisitGet(longid,boolloadGraph=false){conststringsqlVisit=@"SELECT * FROM Visit WHERE Id = @VisitId;";conststringsqlCC=@"SELECT * FROM ChiefComplaint WHERE VisitId = @VisitId;";varsqlParam=new{VisitId=id};if(loadGraph){using(varextractor=base.ExecuteQueryMultiple(sqlVisit+sqlCC,sqlParam)){/*fails with exception*/varv=extractor.Extract<Visit>().FirstOrDefault();varcc=extractor.Extract<ChiefComplaint>().AsList();returnnewVisit(v.Id,v.DateOfService,cc);}}else{using(varextractor=base.ExecuteQueryMultiple(sqlVisit,sqlParam)){returnextractor.Extract<Visit>().FirstOrDefault();}}}
The domain entity that corresponds to the Visit table:
CREATETABLE[dbo].[Visit]([Id]BIGINTIDENTITY(1,1) NOT NULL,[DateOfService]DATETIME2(7) NOT NULL
);CREATETABLE[dbo].[ChiefComplaint]([Id]BIGINTIDENTITY(1,1) NOT NULL,[Description]NVARCHAR(MAX) NULL,[HpiId]BIGINTNULL,[VisitId]BIGINTNULL);
The exception:
HResult=0x80004003Message=Object reference not set to an instance of an object.Source=RepoDbStackTrace:
at RepoDb.Reflection.Compiler.<>c__DisplayClass62_0`1.<GetClassPropertyParameterInfos>b__1(ParameterInfoparameterInfo)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at RepoDb.Reflection.Compiler.GetClassPropertyParameterInfos[TResult](IEnumerable`1 readerFieldsName,IDbSetting dbSetting)at RepoDb.Reflection.Compiler.GetMemberBindingsForDataEntity[TResult](ParameterExpressionreaderParameterExpression,IEnumerable`1readerFields,IDbSettingdbSetting)
at RepoDb.Reflection.Compiler.CompileDataReaderToDataEntity[TResult](DbDataReaderreader,IEnumerable`1dbFields,IDbSettingdbSetting)
at RepoDb.Reflection.Compiler.CompileDataReaderToType[TResult](DbDataReaderreader,IEnumerable`1dbFields,IDbSettingdbSetting)
at RepoDb.Reflection.FunctionFactory.CompileDataReaderToType[TResult](DbDataReaderreader,IEnumerable`1dbFields,IDbSettingdbSetting)
at RepoDb.FunctionCache.DataReaderToTypeCache`1.Get(DbDataReader reader, IEnumerable`1 dbFields, IDbSetting dbSetting)
at RepoDb.FunctionCache.GetDataReaderToTypeCompiledFunction[TResult](DbDataReaderreader,IEnumerable`1dbFields,IDbSettingdbSetting)
at RepoDb.Reflection.DataReader.<ToEnumerable>d__0`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)at System.Linq.Enumerable.ToList[TSource](IEnumerable`1source)
at RepoDb.Extensions.EnumerableExtension.AsList[T](IEnumerable`1value)
at RepoDb.QueryMultipleExtractor.Extract[TEntity](BooleanisMoveToNextResult)
at Repositories.VisitRepository.Get(Int64id,BooleanloadGraph)
I tried to implement the property handler per the docs on RepoDb but with no success. Below is how I implemented the property handler.
In my data layer project I have a DependencyInjection.cs class that implements configuration requirements and gets called in ConfigureServices as below. This is where I specify the FluentMapper mapping.
The latest version of the library has supported the immutable classes and that it requires the ctor fields to be matching from the data reader columns.
Below is our recommendation.
Your Visit class must not have the chiefComplaints argument in the ctor.
Bug Description
Taken from: https://stackoverflow.com/questions/65946130/repodb-extract-function-throws-exception-when-using-executequerymultiple
When I execute the code below, it generates an exception. Where am I going wrong?
Code that generates exception specifically
extractor.Extract
:The domain entity that corresponds to the Visit table:
The base domain entity that all domain entities inherit from:
The Visit and ChiefComplaint tables:
The exception:
I tried to implement the property handler per the docs on RepoDb but with no success. Below is how I implemented the property handler.
In my data layer project I have a DependencyInjection.cs class that implements configuration requirements and gets called in ConfigureServices as below. This is where I specify the FluentMapper mapping.
The ConfigureServices section of Startup.cs in the web api project.
Library Version:
Example: RepoDb v1.12.6 and RepoDb.SqlServer v1.1.2
The text was updated successfully, but these errors were encountered: