0
Reply

how to take value from array from mongodb collection

sreepathy s prabhu

sreepathy s prabhu

Jun 23 2015 7:21 AM
425
how to take value from array from mongodb collection and am using mvc
 
public class PaydeskUser
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string id { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
[Required]
public string Password { get; set; }
[Required]
public string CompanyName { get; set; }
[Required]
public string IndustryName { get; set; }
[Required]
public string Address { get; set; }
[Required]
public string ZipCode { get; set; }
[Required]
public string City { get; set; }
[Required]
public string RegisteredDate { get; set; }
public string ContactPerson { get; set; }
[Required]
public string Status { get; set; }
public string Licence { get; set; }
public string OrganizationNumber { get; set; }
public List<User> Users { get; set; }
}
public class User
{
public User()
{
PayDesks = new List<Paydesk>();
}
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Phone { get; set; }
public string Status { get; set; }
public string Date { get; set; }
public string ProfilePicture { get; set; }
public List<Paydesk> PayDesks { get; set; }
}
 
 i want to take value from User 
 
 
And in controller i wrote this 
 
try
{
var database = PosConnection.GeniusPayDB;
var collection = database.GetCollection<User>("Company");
return collection.AsQueryable<User>().ToList();
}
catch
{
throw;
}
 
 
 what will be the mistake i had done