Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Marten;
- using Marten.Linq;
- namespace Sample
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- var store = DocumentStore.For(_ =>
- {
- _.Connection("host=localhost;database=sample;password=root;username=postgres");
- _.AutoCreateSchemaObjects = AutoCreate.All;
- });
- using (var session = store.OpenSession())
- {
- var order = new Order {Customer = "Luca"};
- var line = new OrderLine() {Name = "Sample"};
- order.Lines.Add(line);
- session.Store(order);
- session.SaveChanges();
- }
- using (var session = store.QuerySession())
- {
- QueryStatistics stats;
- session.Query<Order>().Stats(out stats);
- Console.WriteLine($"Count({stats.TotalResults})");
- }
- }
- }
- public class Order
- {
- public int Id { get; set; }
- public string Customer { get; set; }
- public List<OrderLine> Lines { get; set; } = new List<OrderLine>();
- }
- public class OrderLine
- {
- public string Name { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement