castle-activerecord

Using Lite Version of Entity in nHibernate Relations?

 ̄綄美尐妖づ 提交于 2020-02-03 05:29:05
问题 Is it a good idea to create a lighter version of an Entity in some cases just for performance reason pointing to same table but with fewer columns mapped. E.g If I have a Contact Table which has 50 Columns and in few of the related entities I might be interested in FirstName and LastName property is it a good idea to create a lightweight version of Contact table. E.g. public class ContactLite { public int Id {get; set;} public string FirstName {get; set;} public string LastName {get; set;} }

Read N consequent items by ActiveRecord

本小妞迷上赌 提交于 2020-01-25 13:07:27
问题 My project is C# and uses CastleProject ActiveRecord on MS SQL Server database. I need to retrieve N consequent items from the database, sorted by some criteria, started from some value. Example: I have a lot of messages in some table, where message has ID, time and text. I'd like to retrieve messages with position from 100 to 120, when they are sorted by time. I cannot read all messages, and then sort and find on a client because there may be many messages in database (say it, a million of).

Return entity via projection query

扶醉桌前 提交于 2020-01-21 05:29:07
问题 Is it possible to return an entity using a projection query? I've successfully done it with a SQL query (see below), but can't find how to do it with a projection query. Dim sql As String = "SELECT {a.*}, {b.*} FROM a LEFT OUTER JOIN b ON a.pk = b.fk") ' Convert SQL results into entities {a} and {b} Dim query As IQuery = session.CreateSQLQuery(sql) _ .AddEntity("a", GetType(a)) _ .AddEntity("b", GetType(b)) Return query.List() 回答1: Yes, you can return entities from projection queries. If you

Add SQL query options to NHibernate query

别说谁变了你拦得住时间么 提交于 2020-01-06 14:27:53
问题 I'm working with some code that generates ICriteria queries for NHibernate. They get executed using ActiveRecord and ActiveRecordMediator.FindAll() For certain queries, I need to optimise them by adding on an OPTION (HASH JOIN) hint at the end of the SELECT statement. Is there a quick way I can do this? I don't want to rewrite the queries using plain SQL. Well, I'd love to, but they're too complicated. But if, for example, there's an easy way I can trap and modify the SQL before it's pumped

Castle ActiveRecord Table name conflict

孤街浪徒 提交于 2020-01-04 02:34:07
问题 When you run into a reserved word like "User" in NHibernate you would just put single quotes around the offending text and nHibernate will surround the text with square brackets for querying. My question is how do you do the same thing using Castle.ActiveRecord? 回答1: Actually, the portable way to express this is using backticks, e.g.: [ActiveRecord("`User`")] class User {} From the NHibernate Column class: If a value is passed in that is wrapped by ` then NHibernate will Quote the column

Is there a way to disable Castle Active Record validation for an nhibernate session / active record scope

浪子不回头ぞ 提交于 2020-01-03 03:42:22
问题 Is there a way to disable Active Record validation for an nhibernate session / active record scope? I have a scenario whereby we are performing deletion of a large number of items - and in some cases customers have data in their database that will not pass validation (it was captured prior to new validation rules being introduced, or due to manual manipulation of the database etc.) When deleting, due the way the database is constructed, some validation checks on existing entities occur, and

Table Prefix Using Castle Active Record

删除回忆录丶 提交于 2020-01-03 03:29:30
问题 Is there anyway to add a prefix to table names at configuration time using Castle Active Record? [ActiveRecord("Address")] public class Address : ActiveRecord<Address> {} I'd like the actual table created/referenced to be "PRODAddress" or "DEBUGAddress". Is there anything built-in like that I am not seeing? Thank you, [EDIT] I've marked the general answer below, but here is the actual code to implement table prefixes for Castle Active Record: ... ActiveRecordStarter.ModelsCreated +=

Active Record or NHibernate generating invalid Sql for paging on SqlQuery

落爺英雄遲暮 提交于 2020-01-03 02:48:05
问题 When applying Paging (using SetFirstResult and SetMaxResults ) to an ActiveRecord SqlQuery , with nHibernate 2.1.1 GA and ActiveRecord 2.0.1 the following sql is generated: SELECT TOP 40 FROM (, ROW_NUMBER() OVER(ORDER BY account.Name, account.State) as __hibernate_sort_row select account.Name <rest of query> ) as query WHERE query.__hibernate_sort_row > 40 ORDER BY query.__hibernate_sort_row This errors and moreover doesn't run in sql... whereas it should be SELECT TOP 40 * FROM ( SELECT ROW

Visualization of ActiveRecord / NHibernate Entity Model

亡梦爱人 提交于 2020-01-03 00:21:19
问题 Has anyone come across a tool to visualize an ActiveRecord / NHibernate entity model? 回答1: The best thing I can think of is generating a class diagram from VisualStudio of your classes .... 回答2: 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

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

无人久伴 提交于 2020-01-01 19:38:10
问题 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: