castle-activerecord

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

允我心安 提交于 2019-12-23 02:05:46
问题 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? 回答1: 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

ASP.NET MVC - Castle ActiveRecord - Show SQL queries

吃可爱长大的小学妹 提交于 2019-12-22 18:01:59
问题 I'm using ASP.NET MVC with Castle ActiveRecord as my persistance layer. I want to know if it's possible to show the SQL queries being executed on my MySQL server. I know it's possible in a Web application using the "show_sql" property in the Castle XML configuration file, but I don't know how to do it using a Web application, since I don't have access to the Console. I think I can use log4net to do it, but after some research using Google, I haven't been able to come up with a solution. 回答1:

Howto automatically fill fields during save or update with Castle ActiveRecord

丶灬走出姿态 提交于 2019-12-22 08:13:21
问题 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

How to map a database view using ActiveRecord?

烂漫一生 提交于 2019-12-19 10:51:55
问题 Has anybody tried mapping database views in oracle using ActiveRecord? Please can I get some sample code for that? 回答1: 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

Castle Project ActiveRecord - can it use stored procedures with SQLServer 2005?

懵懂的女人 提交于 2019-12-19 10:46:19
问题 I am new to Castle Project ActiveRecord. I have starting getting my hands dirty and I just seen that It can generate for you the schema, add data, update data to the schema. There are advantages of using stored procedures in SQL Server 2005, one of them being they are precompiled. Is there a way of telling Active Records to use a particular stored procedure when inserting/editing data to the schema? 回答1: ActiveRecord uses NHibernate. See here for information on how to use stored procedures

.NET ORM solution with class auto-generation: Subsonic, Castle AR, …?

若如初见. 提交于 2019-12-19 02:06:11
问题 I used to work with a custom data mapping library, and curently I'm trying to switch to a more widespread ORM solution. After some experimentation, I refined my requirements to the following: able to generate usable classes from database schema (SQL Server support is enough), support for ActiveRecord pattern, programmaticaly configurable (via code or attributes, no HBM files), free. Could you please recommend one? So far I have tried: Subsonic 3.0 The one I currently like most, as it feels

Nhibernate HQL where IN query

纵饮孤独 提交于 2019-12-18 04:39:04
问题 Im trying to return a SimpleQuery list that queries a single table and uses IN. I can get this to work using return new List<Jobs>( ActiveRecordMediator<Jobs>.FindAll(Expression.In("ServiceId", ids)) ); However this is really really really slow. So id like to do something like this SimpleQuery<Job> query = new SimpleQuery<Job>(@"from Job as j where ? in (j.ServiceId)", ids); return new List<Job>(query.Execute()); However I cant get the SimpleQuery to work. I cant find any documentation

Programmatically configure ActiveRecordFacility for multiple databases

ぃ、小莉子 提交于 2019-12-13 05:45:48
问题 I'm trying to build a small application (ASP.NET MVC) that uses the plugin architecture. Along with Castle ActiveRecord Integration Facility. And I wish to let each plugin configure its own ActiveRecord behaviors. Like database connection string, proxy, etc.. However, I couldn't find a way to set multiple configurations without the use of web.config. The idea is to make this programmatically. My goal is for each plugin in this system, if it defines its own ActiveRecord settings, the main

Invalid index n for this SqlParameterCollection with Count=m

点点圈 提交于 2019-12-12 17:17:57
问题 I'm getting this nasty error in Castle Active Record (wrapped around NHibernate) when I try to save a class: Invalid index n for this SqlParameterCollection with Count=m I know that this error is caused by a property being mapped multiple times in a class however I'm not sure how to get around it. I have two child classes that both map back to the class in question using the same column (IpAddressNumber). Also IpAddressNumber is the primary key of the class, which results in NHibernate trying

LINQ's *OrDefault throws exceptions in MVC3 + ActiveRecord

我们两清 提交于 2019-12-12 13:25:59
问题 Spurred on by this question, I decided to try this in my MVC3/ActiveRecord application. I have a bunch of models already working, and some views that do stuff with those models. Nothing special here. One of my models is called AppSession . Based on said question, I expected this to work: AppSession.FirstOrDefault(a => ...) ?? null . It didn't work. I still get an InvalidOperationException . This is true of FirstOrDefault and SingleOrDefault . I ended up wrapping my call in try/catch to get