Click here to Skip to main content
16,022,971 members

Comments by A Belal (Top 14 by date)

A Belal 19-Dec-23 13:01pm View    
Deleted
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.ValidateKeyPropertiesAndExtractCancellationToken(Object[] keyValues, Boolean async, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.FindAsync(Object[] keyValues, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.FindAsync(Object[] keyValues)
at BL.Repositories.BaseRepository`1.<getbyidasync>d__3.MoveNext() in E:\Programming\على folder\SoqRepository\BL\Repositories\BaseRepository.cs:line 53
A Belal 19-Dec-23 12:54pm View    
Notice
when i do breakPoint
and stop in every Line

the Code in this Line is appear as below

{
return LapShopContext.Set<t>().Find(id);
id = 0x00000094
}
A Belal 19-Dec-23 8:45am View    
i make abreakPoint
and debug code

and Error in this Line below
public T GetById(int? id)
{
try
{
if (id.HasValue)
{
Error in this Line below
this :
return LapShopContext.Set<t>().Find(id.Value);


System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.ValidateKeyPropertiesAndExtractCancellationToken(Object[] keyValues, Boolean async, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Find(Object[] keyValues)
at BL.Repositories.BaseRepository`1.GetById(Nullable`1 id) in E:\Programming\على شاهين كورس\SoqRepository\BL\Repositories\BaseRepository.cs:line 53



}
else
{
return null;
}
}
catch (Exception)
{
return null;
}
}
A Belal 18-Dec-23 16:47pm View    
i tried your code
and Error Here



public T GetById(int? id)
{
try
{
return LapShopContext.Set<t>().Find(id); => this Line

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.ValidateKeyPropertiesAndExtractCancellationToken(Object[] keyValues, Boolean async, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Find(Object[] keyValues)
at BL.Repositories.BaseRepository`1.GetById(Nullable`1 id) in E:\Programming\Folder\SoqRepository\BL\Repositories\BaseRepository.cs:line 51




}
catch (Exception)
{
return null;
}
}
A Belal 18-Dec-23 16:28pm View    
the same error

and
Notice
when i do breakPoint
and stop in every Line

the Code in this Line is appear as below

{
return LapShopContext.Set<t>().Find(id);
id = 0x00000094
}






in address bar https://localhost:7201/admin/item/Delete?ItemId=19

my page is
This page isn’t workingIf the problem continues, contact the site owner.
HTTP ERROR 400