I pass two parameters to my repository to return one record
I am strugling to wite the code to return one record.
Here is my repository-
  public Classifieds_Ads GetUserClassifiedDetailsToModify(int classifiedid, Guid UserGuid)
        {
            return context.Classifieds_Ads.Where(c => c.User.Id == UserGuid && c => c.CatID == classifiedid);        
        }
I think you guys can see what I am trying to do but I just write the code. Can I have some help please!
It annoying because I know I will be licking mt self when i see the soloution.
I am 开发者_开发问答also using a stroingly typed views.
Thanks,
Try this:
public Classifieds_Ads GetUserClassifiedDetailsToModify(int classifiedid, Guid UserGuid)
{
    return context.Classifieds_Ads.Where(c => c.User.Id == UserGuid && c.CatID == classifiedid).First();        
}
If your data is returning more than one row you could ask it to return the first row by using the First extension method:
Where(c => c.User.Id == UserGuid && c.CatID == classifiedid).First()
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论