Skip to content

Retrieve specific record from database in MVC

Shibly Sadik

Asked Jul 8, 2015, 7:15 AM EDT1 answer
Share
LinkedInX
Please look at my sample code below:

public class LoginModel
{
[Key]
public int LoginId { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
public class RegisterModel
{
[Key]
public int RegisterId { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string Email { get; set; }
}

public class Cart
{
[Key]
public int RecordId { get; set; }
public string CartId { get; set; }
public int ProductId { get; set; }
public int Count { get; set; }

}

There are many records in the cart table added by many users.
But i want to show the own record of a user from the cart table if he is logged in..how can I do this??

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Manoj Bhoir
    0
    Hi,
     
    You said you want to show User's own records from the Cart Table.
     
    But from your current Cart Table structure I don't think you will get such type of data because there is no columns like UserId or RegisterId in Cart table. So you can not distinguish between the Cart data of multiple user.
     
    So here i would like to suggest you that add one column in your Cart Table which contains UserId or RegisterId so based on that you can filter specific data for that particular user from the table.
    0