castle-activerecord

Castle ActiveRecord Error With View: NHibernate.PropertyNotFoundException for generated key

你说的曾经没有我的故事 提交于 2019-12-12 06:56:14
问题 I'm mapping a view using ActiveRecord, which means I need a primary key. I don't have one, so I'm using ROW_NUMBER() to create one in the view definition to placate the system. However, I don't seem to know how to map it properly. I'm getting: Could not find field 'stupidID' in class 'blah_blah' NHibernate.PropertyNotFoundException: Could not find field 'stupidID' in class 'blah_blah' My mapping looks like this. There is no public long? stupidID; [PrimaryKey("StupidId", Access =

Castle ActiveRecord error “Session is closed”

為{幸葍}努か 提交于 2019-12-12 01:18:03
问题 I'm trying to get started with Castle ActiveRecord but I'm stuck trying to make it work in an ASP.NET (MVC, if it matters) application. In fact I'm getting an ObjectDisposedException during a query with the following message: Session is closed! Object name: 'ISession'. I'm initializing ActiveRecord from an XML file (as shown in the getting started) of which the contents are: <?xml version="1.0" encoding="utf-8" ?> <activerecord isWeb="true" isDebug="true" threadinfotype="Castle.ActiveRecord

How to retrieve the last insert ID in Castle ActiveRecord?

Deadly 提交于 2019-12-11 19:28:42
问题 I'm using ActiveRecord by CastleProject with MySQL in my solution. I wanted to retrieve the last insert ID, so I did something like this: [ActiveRecord] public class UserDb : ActiveRecordBase<UserDb> { [PrimaryKey] public uint Id { get; set; } [Property] public int OtherStuff { get; set; } } public void Blablabla() { UserDb user = new UserDb(); user.OtherStuff = 123; user.CreateAndFlush(); Console.WriteLine( user.Id ); } Sometimes, it outputs the correct ID, but sometimes, it just outputs 0.

How to determine order number of an item in sorted table

前提是你 提交于 2019-12-11 12:21:34
问题 (continued from Read N consequent items by ActiveRecord) My project is C# and uses CastleProject ActiveRecord on MS SQL Server database. I need to understand the order number of an item from a database, if some sorting criteria applied. Example: I have a lot of messages in some table, where message has ID, time and text. I'd like to understand which number particular message will have, if I sort messages by time. Next time, I'd like to get order number of the same message when sort by text

Mapping lookup tables

情到浓时终转凉″ 提交于 2019-12-11 02:02:18
问题 I have several tables that all reference the same lookup table. Is it generally a good idea to attach the BelongsTo attribute to each table that references a FK from a lookup table? Or should I model the foreign keys as a property and simply link the two tables while constructing my detached criteria? 回答1: Not sure I understand the question, but if you're asking whether to do this: [BelongsTo("id_lookup")] public virtual Lookup Lookup {get;set;} or this: [Property("id_lookup")] public virtual

Using Castle ActiveRecord with Fluent NHibernate?

旧时模样 提交于 2019-12-10 19:59:40
问题 Has anyone gotten Fluent NHibernate to work with Castle ActiveRecord? I am particularly interested in Automapping to configure entities for use with the ActiveRecordMediator repository. 回答1: This combo doesn't work yet. When trying to use ActiveRecordMediator on a FluentNHibernate-configured entity you'll get an ActiveRecordException complaining that you didn't call ActiveRecordStarter.Initialize() or you didn't use the [ActiveRecord] attribute. However there is work being done on this

Timeout exception when timeout set to infinite time

心不动则不痛 提交于 2019-12-10 18:48:40
问题 In my C# .NET 3.5 application I am using CastleProject ActiveRecord over NHibernate. This is desktop application using MS SQL Server 2008. I have set ADO command timeout to 0 to prevent timeout exception during bulk operations: <activerecord> <config> ... <add key="hibernate.command_timeout" value="0" /> </config> </activerecord> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> ... <property name="command_timeout">0</property> </session-factory> </hibernate

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

微笑、不失礼 提交于 2019-12-10 11:28:46
问题 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? 回答1: I finally found a

Timeout exception when using NHibernate TransactionScope

五迷三道 提交于 2019-12-10 11:17:57
问题 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

Ditching ActiveRecord and NHibernate — how to rearchitect?

萝らか妹 提交于 2019-12-10 11:11:16
问题 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