castle-activerecord

nhibernate hql with named parameter

人走茶凉 提交于 2019-12-10 03:00:44
问题 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

How to use Linq with Castle ActiveRecord

走远了吗. 提交于 2019-12-08 23:34:19
问题 I am playing around with Castle ActiveRecord and noticed that the download included the file, Castle.ActiveRecord.Linq.dll . I haven't found any documentation for using Linq with ActiveRecord, only some old blog posts. What is the usage pattern? Is Castle.ActiveRecord.Linq ready for production use? 回答1: Yes, Castle.ActiveRecord.Linq is production ready. It's included in the latest ActiveRecord release. The actual Linq provider is implemented in NHibernate.Linq.dll, the ActiveRecord Linq dll

Recommended approach to insert many rows with Castle ActiveRecord and ignore any dupes

风格不统一 提交于 2019-12-08 19:28:33
问题 I have a webmethod that inserts a bunch of recipes into a queue in the database (to store recipes the user is interested in cooking, similar to NetFlix's movie queue). The user is able to check off a bunch of recipes at once and queue them. I have code similar to this: [WebMethod] public void EnqueueRecipes(SecurityCredentials credentials, Guid[] recipeIds) { DB.User user = new DB.User(credentials); using (new TransactionScope(OnDispose.Commit)) { foreach (Guid rid in recipeIds) { DB

How to Generate Castle ActiveRecord C# Classes for an Existing Database

佐手、 提交于 2019-12-08 05:33:25
What is the best way to generate C# classes for use with Castle ActiveRecord and NHibernate given an existing database structure? Can you recommend any of the class generation tools or is it just less hassle to write the classes by hand? Michael Maddox If you only have a handful of tables with not many columns, it may be best to write your classes by hand. I wouldn't recommend hand writing many classes though if your database already exists. Active Writer may meet your needs: http://using.castleproject.org/display/Contrib/ActiveWriter There are other code generators in various states of

NHibernate / ActiveRecord: How to set foreign key without getting entire object?

孤街醉人 提交于 2019-12-07 15:14:04
问题 Let's say I've got the following ActiveRecord class: [ActiveRecord] public class Account { ... [BelongsTo("CustomerId")] public Customer Customer { get; set; } } Currently, to set the value of the CustomerId field I have to get the entire Customer object from the database and assign it to the Account: Customer customer = Customer.FindById(1); account.Customer = customer; This isn't very efficient. I'd rather set the value of CustomerId field directly without round-tripping the database, e.g.

Visualization of ActiveRecord / NHibernate Entity Model

耗尽温柔 提交于 2019-12-07 02:37:31
Has anyone come across a tool to visualize an ActiveRecord / NHibernate entity model? The best thing I can think of is generating a class diagram from VisualStudio of your classes .... Check out ActiveWriter . Sample screenshot: alt text http://img30.imageshack.us/img30/1001/modelingsurface.png 来源: https://stackoverflow.com/questions/1271626/visualization-of-activerecord-nhibernate-entity-model

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

谁说胖子不能爱 提交于 2019-12-06 14:09: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

NHibernate: Creating a criteria which applies for all queries on a table

百般思念 提交于 2019-12-06 13:32:45
Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion on all queries on a table? For example, a good amount of of my tables have a "UserId" column. I might want to ensure that I am always selecting rows for the logged in user. I can easily create an ICriterion object, but I am forced to supply it for different methods: FindAll(), FindFirst(), FindLast() etc. Is there a way to force a WHERE clause on all queries to a Castle ActiveRecord? I finally found a great solution (using filters). Since Castle AR does not have any native API for mapping to NHibernate filters,

Ditching ActiveRecord and NHibernate — how to rearchitect?

空扰寡人 提交于 2019-12-06 12:35:12
I have an MVC3 NHibernate/ActiveRecord project. The project is going okay, and I'm getting a bit of use out of my model objects (mostly one giant hierarchy of three or four classes). My application is analytics based; I store hierarchial data, and later slice it up, display it in graphs, etc. so the actual relationship is not that complicated. So far, I haven't benefited much from ORM; it makes querying easy (ActiveRecord), but I frequently need less information than full objects, and I need to write "hard" queries through complex and multiple selects and iterations over collections -- raw SQL

Timeout exception when using NHibernate TransactionScope

倖福魔咒の 提交于 2019-12-06 09:20:21
This is continuation of Timeout exception when timeout set to infinite time (and I also see unanswered SqlConnection and TransactionScope Timeout question). I am using CastleProject ActiveRecord over NHibernate, C# 3.5. I have multiple subsequent inserts to a database within TransactionScope. One of them (random, different each time) fails with TimeoutException. Whichever timeout I set in my config file (10 hours), this does not matter. If I do not use transaction scope, it work (but too slow). It seems, NHibernate transaction has default timeout 30 second and is not affected by hibernate