Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. public static ISessionFactory CriaConexao()
  2. {
  3. try
  4. {
  5. if (SessionFactory == null)
  6.  
  7. lock (typeof(NHibernateHelper))
  8. {
  9. FluentConfiguration configuration = Fluently.Configure()
  10. .Database(MsSqlConfiguration.MsSql2012.ConnectionString(c => c.FromConnectionStringWithKey("MyConnectionString")
  11. .ShowSql())
  12. .Mappings(c => c.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())).
  13. configuration.BuildSessionFactory();
  14. }
  15.  
  16. return SessionFactory;
  17. }
  18. catch (Exception ex)
  19. {
  20. Log.write(ex.ToString());
  21. throw;
  22. }
  23. }
  24.  
  25. // {“Valor não pode ser nulo.rnNome do parâmetro: Data Source”
  26.  
  27. <?xml version="1.0" encoding="utf-8"?>
  28. <configuration>
  29. <configSections>
  30. </configSections>
  31. <connectionStrings>
  32. <add name="MyConnectionString" connectionString="Data Source=CARLOSSQLEXPRESS;Initial Catalog=PAF-ECF;Integrated Security=True"
  33. providerName="System.Data.SqlClient" />
  34. </connectionStrings>
  35. <startup> E:PROJETO C#AutomacaoComercialFrenteCaixaApp.config
  36.  
  37. <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup>
  38. <runtime>
  39. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  40. <dependentAssembly>
  41. <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
  42. <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
  43. </dependentAssembly>
  44. </assemblyBinding>
  45. </runtime>
  46. </configuration>
Add Comment
Please, Sign In to add comment