static void Main(string[] args) { const string ticker = "test2"; CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; var testQuote1 = new StockQuote { Ticker = ticker, Date = 20180101, Open = 11, High = 12, Low = 10, Close = 11.2, Volume = 100 }; var testQuote2 = new StockQuote { Ticker = ticker, Date = 20180102, Open = 11, High = 12, Low = 10, Close = 11.2, Volume = 100 }; var stock = new Company { Ticker = ticker, Quotes = new Collection <StockQuote> { testQuote2 } }; const string connectionString = @"server=(localdb)\MSSQLLocalDB;Initial Catalog=StockMarketDb;Integrated Security=True;"; var factory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012 .ConnectionString(connectionString).ShowSql()) .Mappings(m => m.FluentMappings .Add <CompanyNhibernateMap>() .Add <StockQuoteNhibernateMap>() ) .ExposeConfiguration(c => SchemaMetadataUpdater.QuoteTableAndColumns(c)) .BuildSessionFactory(); var session = factory.OpenSession(); session.Save(stock); session.Flush(); }
public virtual bool ValueEquals(StockQuote other) { return(other.Ticker == Ticker && other.Date == Date); }