Skip to content

Instantly share code, notes, and snippets.

View AbhinavPradeep's full-sized avatar

Abhinav Pradeep AbhinavPradeep

View GitHub Profile
private static void FindCustomer(IMongoCollection<Person> collection, int id)
{
var persons = collection.Find<Person>(person => person._id == id).ToList();
foreach (var person in persons)
{
PrintPerson(person);
}
}
private static void FindCustomer(IMongoCollection<Person> collection, int id)
{
var persons = collection.Find<Person>(person => person._id == id).ToList();
foreach (var person in persons)
{
PrintPerson(person);
}
}
private static void FindCustomer(IMongoCollection<Person> collection, int id)
{
var persons = collection.Find<Person>(person => person._id == id).ToList();
foreach (var person in persons)
{
PrintPerson(person);
}
}
private static void PrintPerson(Person person)
{
Console.WriteLine($"Person ID is {person._id}");
Console.WriteLine($"Person first Name is {person.FirstName}");
Console.WriteLine($"Person Last Name is {person.LastName}");
Console.WriteLine($"Person HouseNum is {person.Address.HouseNum}");
Console.WriteLine($"Person Street is {person.Address.Street}");
Console.WriteLine($"Person Area is {person.Address.Area}");
Console.WriteLine($"Person state is {person.Address.State}");
Console.WriteLine($"Person country is {person.Address.Country}");
private static void DeleteCustomer(IMongoCollection<Person> collection, int id)
{
var result = collection.DeleteOne<Person>(x => x._id == id);
if (result.DeletedCount > 0)
Console.WriteLine("deleted");
}
private static void UpdateRename(IMongoCollection<Person> collection, int id,string field, string renamed)
{
var update = Builders<Person>.Update.Set(field,renamed);
collection.UpdateOne(x => x._id == id,update);
}
static void Main(string[] args)
{
IMongoCollection<Person> collection = InitializeDatabase();
if (args[0] == "Add")
{
AddCustomer(collection);
}
else if (args[0] == "List")
{
using System;
namespace LnkdList
{
public class Node
{
public Node Next;
public Person person;
public Node()
using System;
namespace LnkdList
{
public class Person
{
public string Name {get;set;}
}
}
Node Head;
public LinkedList()
{
Head = null;
}