//**** package install, person class, main class code
Install-Package MongoDB.Entities
//************************* main class
using System; using MongoDB.Entities; using System.Threading.Tasks; namespace ConsoleAppMongo { class Program { private async static Task Main() { await DB.InitAsync("MyDatabase", "localhost", 27017); var lisa = new Person { Name = "Lisa Malfrey", DateOfBirth = new DateTime(1983, 10, 11), SiblingCount = 1 }; await lisa.SaveAsync(); Console.WriteLine($"Lisa's ID: {lisa.ID}"); Console.Read(); } } }
//************************* person class
using MongoDB.Entities;
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleAppMongo
{
public class Person : Entity
{
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
public int SiblingCount { get; set; }
}
}
//*************************
Yorumlar
Yorum Gönder