ADO.NET :: How To Use Fluent Nhibernate - Finding Tutorials
Nov 9, 2010
, I want to use fluent hibernate with asp.net but couldn't find any website or tutorial for that , they're all to configure it with asp.net mvc , anyone knows any?
I am using the above combo in a new web app Im doing just to try to learn to build new stuff to expand my knowledge. Im hoping to go live if I do a good job.. Im kind of new at MVC and the other products so I was trying to find a link to a good tutorial that set all of these up together.
I have a session criteria statement (Fluent NHibernate) that does not seem to filter the child collection even though I have Expressions/Restrictions defined.
This returns all the objects of type MyClass that have MyCollection.Property = value, however MyCollection is not filtered to MyCollection.Property = value
We are developing a multi-language web application with ASP.NET MVC 2 and Fluent NHibernate.Our platform will be multi-language. But just static text will be multi-language. Groups pages depends on community content whatever they use. Like Facebook.We decide to keep all language string in database. And load language when application starts.
I have the following models & mappings (code snippets further below).
One Competition has to have multiple CompetitionAnswers associated with it (multiple choice) from the outset.
At present, using the Fluent NHibernate mappings shown below, when I create a brand new Competition object, populate the properties, then create 3 brand new CompetitionAnswer objects and add them to the CompetitionAnswers property (property on Competition), I would expect to call Save on the session which would INSERT the 1 Competition row and 3 CompetitionAnswer rows to the DB.
However, as soon as I try to call Save on the session, it complains that CompetitionId is null and it can't insert a null into the CompetitionAnswers table for that field - which is right, it shouldn't, however, I assumed that the NHibernate would first create the Competition, then use the newly generated IDENTITY value (CompetitionId) in the CompetitionAnswers table?
I've upgraded an ASP.Net Web application to the latest build of Fluent NHibernate (1.0.0.636) and the newest version of NHibernate (v2.1.2.4000). I've checked a couple of times that the application is running in Full trust. But I keep getting the following error:
Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Anyone had a similar error? I've seach the web / stackoverflow / NHibernate forums but only found people who had a problem when running in medium trust mode, not full trust. I've been developing for several months on this application on this machine with previous versions of Fluent NHibernate and NHibernate.
The machine I'm running this on is 64-bit, you never know that this is relevant.
I'm working on a RoleProvider in .NET, using Fluent NHibernate to map tables in an Oracle 9.2 database.
The problem is that the many-to-many table connecting users and roles uses a primary key generated from a sequence, as opposed to a composite key. I can't really change this, because I'm writing it to be implemented in a larger existing system.
Here is my UserMap:
public UserMap() { this.Table("USR");[code].....
Yet, this is giving me the error:
Type 'FluentNHibernate.Cfg.FluentConfigurationException' in assembly 'FluentNHibernate, Version=1.0.0.593, Culture=neutral, PublicKeyToken=8aa435e3cb308880' is not marked as serializable.
Is there a simple fix to allow this HasMayToMany to use my PersistentObjectMap extension? I'm thinking I may have to add a convention for this many-to-many relationship, but I don't know where to start with that, since I've just started using NHibernate and Fluent NHibernate only recently.
EDIT: I think I've found a possible solution here: http://marekblotny.blogspot.com/2009/02/fluent-nhbernate-and-collections.html
I'll try the above method of creating an entity and a class map for the linking table and post my findings.
EDIT 2: I created a linking entity as mentioned in the above blog post and downloaded the newest binaries (1.0.0.623). This helped me discover that the issue was with setting lazy load and trying to add roles to the user object in a completely new session.
I modified the code to move OpenSession to the BeginRequest of an HttpModule as described here. After doing this, I changed my data access code from wrapping the open session in a using statement, which closes the session when it is finished, to getting the current session and wrapping only the transaction in a using statement.
This seems to have resolved the bulk of my issue, but I am now getting an error that says "Could not insert collection" into the USR_ROLE table. And I'm wondering if the above code should work with a UserRoleMap described as:
public UserRoleMap() { this.Table("USR_ROLE"); [code]....
Hibernate's documentation for many-to-many relationship suggests creating an object to maintain a one-to-many/many-to-one, as in an ERD. I'm sure this would be much easier with conventional naming standards, but I have to stick with certain abbreviations and odd (and not always properly-implemented) conventions.
am trying to implement fluent nhibernate in MVC project...there were no build errors... but when i run the project i get this exception
System.Xml.Schema.XmlSchemaValidationException: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.
have no idea what am doing wrong here... the following is the code for opening session factory...
I am using asp.net sitemap with the in-built asp.net menu but this is very 'dull'. I want to apply CSS and jQuery to give it a better visual look and feel. I have read various articles based on[URL] However, i really liked
[URL]
Is there any examples or tutorials similar to this which are FREE?
Various tutorials and articles describing the N-tier architecture use the "Open Late Close Early" methodology for Connection objects. The connection is just opened before a "ExecuteNonQuery or ExecuteReader" command, and closed immediately
This means that inside a transaction where a number of business objects have to be updated (using different DAL classes), the connection can be opened and closed many times.
In that case the transaction will be escalated to a distributed transaction. Now we can’t assume that MSDTC will be availableunning every where. Now if I am building a website to be uploaded using those shared web hosting services, which does not allow MSDTC , what are my options ?
I'm making my debut in designing a web app specifically targeted at mobile browsers. While I've written web pages before in C#/ASP.NET, I've never done anything specifically for the limited screen real estate and other idiosyncrasies of mobile browsers. So I'm looking for some pointers here:
What design considerations should I be taking account of (aside from the obviously smaller screen)?
What useful features are there in C# that can be put to good effect for the mobile client?
How do you make sure to give a relatively uniform user experience for all different mobile browsers?
I need to write an asmx service that takes the xml file as input and also gives an xml as output which are validated using an xsd..
I was trying to read about the services that accept xml inputs and return xml outputs.. but all in vain, I couldn't find a proper tutorial and sample codes to work on..
Can anyone give some links to some nice tutorials and samples with asmx services accepting xml data and returning xml data..
I am trying to figure out how to use/create a custom control in ASP.NET MVC 2.
I created a custom control earlier and compiled it (ccontrol.dll), the control renders a div, textbox and a button + some javascript in order to post a comment on the website. It could be a static aspx page that i wanted to allow my visitors to add a comment to. I would then drag my control from the toolbar to the aspx page and run it, it would then render all the code needed on the webpage including fetching the data from a datasource and displaying that inside the div. The user could also just type in a comment and press the button to save it to the datasource.
Is this possible to convert to MVC 2? Any good tutorial that covers custom controls and MVC 2? (Ideally would be if the control could be made into a .dll file that i then could reuse on future webpages)
How do i write a custom control the mvc way? Any good tutorials on the topic?
I have this web application built. I am using windows authentication for this application. I have to log all the user activity as wells as site activity in this application. I have the below mentioned class established to log some activity regarding the user to an SQL server database table..
[code]....
I would still need to log many other items regarding the user and also the site, like the time spent by the user on the site, no: of currently logged in users on the site. Can anyone here suggest me as to how do I capture those items?? let me know if I am going in the right direction too.....?? If you can provide me with some links on this "user activity logging for windows authenticated applications".
I was wondering if someone can direct me to a good quality tutorial on the process of registering and sending an activation link to the user's email address. I can't seem to find any useful tutorials online!
I am using asp.net sitemap with the in-built asp.net menu but this is very 'dull'. I want to apply CSS and jQuery to give it a better visual look and feel. I have read various articles based on [URL] However, i really liked [URL]
Is there any examples or tutorials similar to this which are FREE?