castle-activerecord

NHibernate and database connection failover?

天涯浪子 提交于 2019-12-31 02:19:15
问题 I am using NHibernate to connect to a legacy rdbms system. Under high production load the rdbms service fails. To maintain the availability we have a failover rdbms service. Is there a way to configure NHibernate to use the FailOver Connection String when the primary connection is down? Additional Info: I am using Castle over NHibernate. If Castle provides handling of failover connections then that will also do it for me. 回答1: You can build your own NHibernate.Connection.IConnectionProvider

mapping view using castle activerecord, exception on primary key

混江龙づ霸主 提交于 2019-12-25 00:29:51
问题 Using answer from this question, I'm trying to map my database view. But, it throw exception because I don't define any PrimaryKey on the mapping class (the view doesn't have any primary key). Do I need to use CompositeKey (this is not recommended, according to castle website) to solve this problem ? Or there is better solution ? 回答1: Quoting the docs: Regular ActiveRecord types must have a primary key, a key that uniquely indentifies any row in a table. Single surrogate keys are favouvered

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

Castle ValidateEmail Attribute fails on plus sign

℡╲_俬逩灬. 提交于 2019-12-24 11:07:57
问题 I am using Castle Validators on my model. I have an EmailAddress property defined like so: [ValidateEmail] public string EmailAddress { get; set; } The problem is that the regex (?) that the ValidateEmail attribute uses is incorrect. For instance, if I put in an email address like foo@foo.com, it validates correctly, but if I put in an address like foo+1@foo.com, it says it is not valid. I realize that I can just use the ValidateRegExp attribute with my own regex, but if possible, I'd prefer

How to create dynamic NHibernate mappings without generating HBM XML files?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 09:06:55
问题 I'm working on a dynamic application with NHibernate. My goal is to create dynamic entities (both class type and mapping xml file) based on some data. For example suppose I want to create a Person entity dynamically in runtime and on the fly. I use Reflection.Emit to generate class type dynamically. For creating mapping dynamically I used Ayende's code.. But unfortunately this code does not work because mappings does not have Classes property. I tried to code as same as codes of Castle

Session Management in Castle Active Record

与世无争的帅哥 提交于 2019-12-24 07:01:06
问题 How do I manage session if I am using Castle Active Record over nHibernate. Basically I can manage the life cycle of ISession on my own if I am using nHibernate directly. But when I am using Castle AR it does not give me a way to manage the life cycle of the session. I want to use single Session per thread. I am using Castle AR in a WCF service and would like to use Session per WCF Request. 回答1: Instead of using ISession, in Castle ActiveRecord you want SessionScope: using(new SessionScope())

Castle ActiveRecord: Map to IUserType wihtin Class in C#

这一生的挚爱 提交于 2019-12-24 00:28:34
问题 for my current project I am using Castle's ActiveRecord in C#. For one of my tables I do need to use a custom type class (dealing with an stupid time to timespan conversion). To keep my code clean I like to define the class which is derived from IUserType within the object mapping class. But I can find no way to map this property using this subclass, ActiveRecord keeps complaining: Could not determine type for (...) Here is a small sample: namespace testForActiveRecord { [ActiveRecord("

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

浪尽此生 提交于 2019-12-23 12:25:02
问题 I have the following code set up in my Startup IDictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect"); properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); properties.Add(

How to stop Automapper from mapping to parent class when child class was requested

烂漫一生 提交于 2019-12-23 08:53:40
问题 I am working on implementing AutoMapper in our service and am seeing a very confusing issue in our unit tests. First off this issue involves the following objects and their respective maps: public class DbAccount : ActiveRecordBase<DbAccount> { // this is the ORM entity } public class Account { // this is the primary full valued Dto } public class LazyAccount : Account { // this class as it is named doesn't load the majority of the properties of account } Mapper.CreateMap<DbAccount,Account>()

How to stop Automapper from mapping to parent class when child class was requested

这一生的挚爱 提交于 2019-12-23 08:52:32
问题 I am working on implementing AutoMapper in our service and am seeing a very confusing issue in our unit tests. First off this issue involves the following objects and their respective maps: public class DbAccount : ActiveRecordBase<DbAccount> { // this is the ORM entity } public class Account { // this is the primary full valued Dto } public class LazyAccount : Account { // this class as it is named doesn't load the majority of the properties of account } Mapper.CreateMap<DbAccount,Account>()