Search code examples
c#mongodbmongodb-.net-driver

Use mongo csharp driver with View


I have a view named test1 that contain a customized and advanced query.

Is it possibly to use mongo csharp driver in order retrieve the data from the view named test1 to the c# application?

Info:
*I'm new in MongoDB and mongo csharp driver.

Thank you!


Solution

  • For retrieving data from a view, you can use the same code as to retrieve data from the collection:

    var view = client
          .GetDatabase(databaseName)
          .GetCollection<TEntity>(viewName)