nhibernate

Castle ActiveRecord / NHibernate - Password Encryption or Hashing

一世执手 提交于 2019-12-25 00:09:43
问题 What is the proper way to work with Passwords you don't want to store in clear text in a database? What are my options in NHibernate / Castle ActiveRecord? UPDATE: I was interested in how others handle this with NHibernate / Castle ActiveRecord. And if there was anything built into NHibernate or Castle ActiveRecord. 回答1: Hash the password. Don't encrypt - it's complex and/or unsafe. There's no conceivable circumstance in which it wouldn't be OK to reset the password based on some other

NHibernate mapping error ([EntityName] not mapped)

时间秒杀一切 提交于 2019-12-25 00:03:31
问题 My project (c#, nhibernate, npgsql, nlog) has one entity named Entry and should be mapped to the database table named test . Table contains some test entries. My application code is as follows: public void work() { ISessionFactory sessions = new Configuration().Configure().BuildSessionFactory(); ISession session = sessions.OpenSession(); IList<Entry> entries = session.CreateQuery("from Entry").List<Entry>(); foreach (Entry e in entries) { logger.Debug("Entry: " + e.id + " with " + e.name); }

How to map PostGis geometry column as wkt with nHibernate not using nHibernate spatial

杀马特。学长 韩版系。学妹 提交于 2019-12-24 22:04:04
问题 I need to read a postgis geometry column as wkt using nHibernate. I know I could use nHibernate Spatial, but that is not an option in my case. I have seen this post: Best way to map a hidden property in NHibernate (fluent) where the wkt is stored in another column and he uses triggers to update the actual geometry. However the project owners do not want to have an extra column for this purpose. I found this thread as well: Use PostGIS columns transparently in Hibernate, but no has provided an

NHibernate and MySql Keywords

吃可爱长大的小学妹 提交于 2019-12-24 19:29:26
问题 Why Nibernate HQL can not handle the following query: from Deal D where (D.ApprovalDate + INTERVAL 1 Year) < current_timestamp() < (D.RenewalDate + INTERVAL -1 Year) knowing that INTERVAL and YEAR are keywords in MySQL, so this is kind of mixing Sql within Hql (unless Hql can handle date functions like so and I don't know) . The dialect is MySQLDialect Its perfectly valid to execute this query SELECT '2005-01-01' + INTERVAL 1 Year; 回答1: You can pass the Sql directly in the query using

NHibernate IQueryOver.ToRowCountQuery() equivalent when Using HQL IQuery

怎甘沉沦 提交于 2019-12-24 19:12:05
问题 I'm trying to implement paging within my project. When using NHibernate's IQueryOver syntax as shown below things are working as expected. public PagedResult<T> ExecutePagedQuery(IQueryOver<T,T> query) { SetPaging(query); var results = query.Future<T>(); var count = query.ToRowCountQuery().FutureValue<int>(); return new PagedResult<T>() { TotalItemCount = count.Value, PageOfResults = results.ToList() }; } protected virtual void SetPaging(IQueryOver<T, T> query) { var maxResults = PageSize;

Map fields from two tables to create a single entity

江枫思渺然 提交于 2019-12-24 19:07:16
问题 I'm working on a feature to add the ability for each of our customers to define a customized registration form for their account and I've run into a bit of a roadblock in creating my Fluent NHibernate mapping for one of the objects. There are two tables involved [RegistrationField] and [AccountRegistrationField] . [RegistrationField] contains a static list of all of the fields that are available to pick from as well as some information on how to render the field (e.g. should it be a textbox,

NHibernate - Version as DateTime, generated in DB

自作多情 提交于 2019-12-24 19:05:10
问题 I'm trying to assign a version column to my table and I want the version to be generated from the DB (getDate()). My mapping looks like that: Version(x => x.Version).Index("idx_Version").Generated.Always(); but when I'm trying to insert a row, I'm getting this error: Cannot insert the value NULL into column 'Version'... column does not allow nulls. I've also tried a different approach and mapped the column as an regular column like this: Map(x => x.Version).Index("idx_Version").Generated

Create Database and Tables with NHibernate and FluentNHibernate?

匆匆过客 提交于 2019-12-24 17:44:16
问题 I'm looking for any way to create database and tables with NHibernate and FluentNHibernate. How could I do this ? trying. private static ISessionFactory createConnection() { if (session != null) return session; //database configs FluentConfiguration _config = Fluently.Configure().Database( MySQLConfiguration.Standard.ConnectionString( x => x.Server(HOST). Username(USER). Password(PASSWORD). Database(DB) )) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PerfilMap>()) .Mappings(m => m

Discriminator based on joined property

旧街凉风 提交于 2019-12-24 17:24:56
问题 Suppose I have this relationship: abstract class Base { int Id; int JoinedId; ... } class Joined { int Id; int Discriminator; ... } class Sub1 : Base { ... } class Sub2 : Base { ... } for the following tables: table Base ( Id int, JoinedId int, ... ) table Joined ( Id int, Discriminator int, ... ) I would like to set up a table-per-hierarchy inheritance mapping for the Base, Sub1, Sub2 relationships, but using the Disciminator property from the Joined class as the discriminator. Here's the

The ConnectionString property has not been initialized after “using”

拈花ヽ惹草 提交于 2019-12-24 17:24:43
问题 My connection string, my database, and everything is working just fine, but just when I call it once at my page. I have several methods that make connection to my database and return a value to me, and for the first time i need to use two of then. And i'm getting this error in conn.Open() : "The ConnectionString property has not been initialized." "Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information