castle-activerecord

How to use XMLSerializer with a Castle ActiveRecord containing an IList<T> member

限于喜欢 提交于 2019-12-06 06:18:46
问题 I am trying to use the XMLSerializer with a castle active record class which looks like the following: [ActiveRecord("Model")] public class DataModel : ActiveRecordBase { private IList<Document> documents; [XmlArray("Documents")] public virtual IList<Document> Documents { get { return documents; } set { documents = value; } } } However, the XMLSerializer runs into trouble because of the IList interface. (Raises exception: Cannot serialize member 'DataModel.Documents' of type 'System

Howto automatically fill fields during save or update with Castle ActiveRecord

左心房为你撑大大i 提交于 2019-12-05 17:43:20
The Problem: All tables in our database have CreatedDate, CreatedBy, ChangedDate, ChangedBy fields which I want to be set automatically when Saving / Updating an ActiveRecord entity. My first try was to override the Save() and Update() methods. But these methods only get called when I do a direct Save() or Update() on the entity. They are not being called in a Master - Detail scenario where I call Save() only on the master. Next try were the OnSave() and OnUpdate() methods, but here changes in the fields were not persisted in the database. Finally I tried the BeforeSave() method. But this

nhibernate hql with named parameter

那年仲夏 提交于 2019-12-05 03:40:38
I have implemented a search function using Castel Active Record. I thought the code is simple enough but I kept getting NHibernate.QueryParameterException : could not locate named parameter [searchKeyWords] errors. Can someone tell me what went wrong? Thanks a million. public List<Seller> GetSellersWithEmail(string searchKeyWords) { if (string.IsNullOrEmpty(searchKeyWords)) { return new List<Seller>(); } string hql = @"select distinct s from Seller s where s.Deleted = false and ( s.Email like '%:searchKeyWords%')"; SimpleQuery<Seller> q = new SimpleQuery<Seller>(hql); q.SetParameter(

Lucene.NET indexes are not updating when dealing with many-to-many relationships using NHibernate.Search

这一生的挚爱 提交于 2019-12-04 19:49:18
I have integrated NHibernate.Search into my web app by following tutorials from the following sources: NHibernate.Search using Lucene.NET Full Text Index (Part 1) Using NHibernate.Search with ActiveRecord I have also successfully batch-indexed my database, and when testing against Luke, I can search for terms that reside in whatever entities I marked as indexable. However , when I attempt to update many-to-many entities via my web app, my parent index does not seem to update. For example: public class Books { HasAndBelongsToMany(typeof(Author), Table = "BookAuthor", ColumnKey = "BookId",

C# Castle ActiveRecord: How to elegantly (XML) serialize ActiveRecord objects?

三世轮回 提交于 2019-12-04 19:10:42
I'm having a difficult time finding information on how to elegantly serialize ActiveRecord objects. We would like to use XML as the format because we need to output our objects in such a way that another program will be able to feasibly parse them. XML-Serialization is usually very easy and straightforward to implement, but the problem comes when trying to serialize an object returned from the ActiveRecord database. The database returns a proxy class of the object, the type of which cannot be explicitly anticipated via the [XmlInclude] attribute. For example: public class Foo :

Parameterizing a HQL IN clause using HqlBasedQuery?

别说谁变了你拦得住时间么 提交于 2019-12-04 12:23:43
问题 How do you pass a list of things for the 'in' clause in Nhibernate HQL? e.g. // data input from the user interface, not known at compile time object[] productIds = {1, 17, 36, ... }; string hqlQuery = @" from Product as prod where prod.Id in ( ? )"; HqlBasedQuery query = new HqlBasedQuery(typeof(Product), hqlQuery, productIds) ActiveRecordMediator.ExecuteQuery(query); Now, this isn't going to work, as much as I wish it would! Am I really stuck doing something like this: // data input from the

Parameterizing a HQL IN clause using HqlBasedQuery?

亡梦爱人 提交于 2019-12-03 07:46:36
How do you pass a list of things for the 'in' clause in Nhibernate HQL? e.g. // data input from the user interface, not known at compile time object[] productIds = {1, 17, 36, ... }; string hqlQuery = @" from Product as prod where prod.Id in ( ? )"; HqlBasedQuery query = new HqlBasedQuery(typeof(Product), hqlQuery, productIds) ActiveRecordMediator.ExecuteQuery(query); Now, this isn't going to work, as much as I wish it would! Am I really stuck doing something like this: // data input from the user interface, not known at compile time object[] productIds = {1, 17, 36, ... }; string hqlQuery = @

Castle Activerecord error is “relation does not exist” on Postgresql?

点点圈 提交于 2019-12-02 18:51:58
问题 ActiveRecord mape: [ActiveRecord("JobTitle",Schema="public")] public class JobTitle :ActiveRecordValidationBase<JobTitle> { [PrimaryKey(Column = "Id")] public virtual int Id { get; set; } [Property(Column = "Description")] public virtual string Description { get; set; } [Property(Column = "Title", NotNull = true)] public virtual string Title { get; set; } } DB connection: DB config: public class DbConfig { public static void Configure() { var connectionString=ConfigurationManager

NHibernate and database connection failover?

这一生的挚爱 提交于 2019-12-01 23:07:19
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. You can build your own NHibernate.Connection.IConnectionProvider which provides failover support. This should be a subclass of ConnectionProvider which overrides

How to map a database view using ActiveRecord?

北战南征 提交于 2019-12-01 13:36:23
Has anybody tried mapping database views in oracle using ActiveRecord? Please can I get some sample code for that? No code necessary: just use the view name instead of the table in your [ActiveRecord] attribute: [ActiveRecord("MyView")] public class Document {...} Be aware that SchemaExport will treat your view as a table, here's how to fix that. 来源: https://stackoverflow.com/questions/2048483/how-to-map-a-database-view-using-activerecord