Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User
- {
- public virtual int id { get; set; }
- public virtual string name { get; set; }
- }
- class MapUser : ClassMap<User>
- {
- public MapUser()
- {
- Id(x => x.id);
- Map(x => x.name);
- }
- static void Main(string[] args)
- {
- string connectionString = "Server=127.0.0.1; Port=5432; User Id=credit; Password=;Database=databir;";
- try
- {
- ISessionFactory sessionFactory = Fluently.Configure().Database(PostgreSQLConfiguration.PostgreSQL81
- .ConnectionString(c => c.FromAppSetting(connectionString)).ShowSql()).Mappings(m => m.FluentMappings.AddFromAssembly(User)).BuildSessionFactory();
- var sefact = sessionFactory;
- using (var session = sefact.OpenSession())
- {
- using (var txt = session.BeginTransaction())
- {
- var use1 = new User
- {
- id = 1,
- name = "jakhongir"
- };
- session.Save(use1);
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- throw;
- }
- }
Add Comment
Please, Sign In to add comment