how to write fluent nhibernate queries? - fluent-nhibernate

I'm new to fluent nhibernate and generally nhibernate.
I searched a lot on the net but I couldn't find a good help.
I'm using fluent nhibernate and I mapped it with SQLServer 2008.
If there is a good help or book or sth else please tell me!
First of all I want to know how I can write native sql queries in my program? for example
DELETE * From SiteCategory
And generally I want to know how to write queries in fluent nhibernate? such as update,delete and select.

A good resource would be this series of screencasts:
Vacation Of Fluent NHibernate:
http://iamnotmyself.com/2009/10/26/vacation-of-fluent-nhibernate-introduction/
[link updated]
It was modeled after the very popular Summer of NHibernate series

Related

NHibernate Query Generator with Fluent mappings

I was trying to find a good way to build dynamic queries with NHibernate and that lead me to NHibernate Query Generator which I like but we currently use Fluent NHibernate mappings and I wasn't sure if there was a way to use NHibernate Query Generator with Fluent NHibernate mappings. Any one have experience with this or know a better way to accomplish dynamic queries?
First, NHibernate already has ways to build dynamic queries (Criteria / QueryOver are specially useful for this). I googled "NHibernate Query Generator" and found a project that was abandoned more than 4 years ago.
Second, the method you use to create your mappings has nothing to do with the query APIs.

How to write Queries for retreving, Checking Existence in NHIBERNATE USING(FLUENTNHIBERNATE)

How to write Queries for retreving, Checking Existence, and all we do in SQL
using NHIBERNATE (FLUENTNHIBERNATE)
Is FluentNhibernate is used in these Queries.
And
Which one is better Fluent Nhibernate Mapping or XML Mapping
Is there any relation or should i know LINQ for learning Nhibernate?
i can see several questions:
"How to write Queries for retreving, Checking Existence": see here for the different querylanguages in NH http://fabiomaulo.blogspot.com/2009/09/nhibernate-queries.html
"Is FluentNhibernate is used in these Queries": no FNH is used to configure NHibernate: alternative for hbm.xml and hibernate.cfg
"Which one is better Fluent Nhibernate Mapping or XML Mapping": in most cases FluentNHibernate is much easier to write than xml and covers 95% of options possible in xml. For beginners i would recommend FluentMappings because a lot of sensible defaults make it easier to get something to work.
"Is there any relation or should i know LINQ for learning Nhibernate?": LINQ is one of 6 ways to query in NHibernate. It is an elegant way but neither required nor the "works in all circumstances".

FluentNHibernate or port to NHibernate mapping by code

I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate.
Question: Contribute to FNH or to migrate the mappings to mapping-by-code or confORM and fixing problems/implementing features there?
At our office, we have been using NHibernate for 3 years now. We've been thinking about making a move to Fluent Nhibernate but never made the move. Using hbm.xml files was still the easiest to debug/alter. Two common problems of those xml files are that they are all validated during the creating of the sessionfactory and they are not refactor-safe.
Due to a bug I had to update a newer release of NHibernate (we were using NHib 2.1.2GA) and when I implemented 3.2GA we also were handed the ability to use loquacious mappings (mapping by code). I decided to use Loquacious over Fluent because I don't have a dependency to another project (Fluent) and the fact that NHibernate won't be shipped if mapping by code is broken.
Be aware though, that Loquacious mapping isn't complete either. While I was mapping everything by code, I found out basic stuff like property-ref wasn't always implemented. Thus even though it's shipped, it's not 100% complete. And while this will not come as a shocker, it has bugs. yes. really. ;-)
for more info on (reported) bugs, check out the NHibernate bug database: https://nhibernate.jira.com/browse/NH
Hope this helps.
Regards, Ted
thx to #TedOnTheNet i will continue to use and contribute to FNH, because it will take a while until mapping-by-code reaches FNH in some areas
Automapping
Fluent API tells a lot better which possibilities there are
far more verbose mappings
.Database(SQLiteConfiguration.Standard.InMemory()) is still easier to figure out than
.DataBaseIntegration(db =>
{
db.ConnectionString = ???;
db.Dialect<SQLiteDialect>();
db.Driver<???>();
});
and some features:
CompositeId and Table per Subclass
default values for legacy columns
property refs
Update: some features from hbm.xml (and FluentMapping) will not be possible at all with mapping by code:
default values for legacy columns: database column to constant value without the need for a property in the entity class with mapping by code
query only properties/collections: http://ayende.com/blog/4054/nhibernate-query-only-properties
NH 3.2 does not have anything remotely equivalent to FNH's Automapping, as far as I can tell. (For me, that would be a dealbreaker).
Edit
The FNH Automapper can deal with most of the common patterns in an object model, such as inheritance, one-to-many relationships, self-referencing, etc - without requiring any help from the programmer. So far, pure NH has not achieved this level of automation.
Also, James Gregory has publicly stated that he will continue to develop FNH, at least in the near term. (Think I saw this on the FNH Google group a few months back, but I'm not sure exactly where).

Fluent Nhibernate Connect to Firebird

I'm having trouble getting a connection to a Firebird database. I can't seem to find too much information on Fluent NHibernate and Firebird on the Internet which lead me to here.
Can anyone provide any insight on how to connect Fluent NHibernate to a Firebird database in C#? I'm specifically writing a WPF application.
There shouldn't be anything specific to Fluent nHibernate that causes problems with Firebird or any other database for that matter - that's the point of nHibernate, and FnH is just a layer above it.
If you post some errors someone might be able to better help you, because it's impossible to know what it is that's wrong. Can you connect to Firebird through a normal NH mapping in your current environment, for example?

nHibernate - Generate classes from a database?

I know that you can generate a database from classes and their mappings using nHibernate, but I can't find any good links to do this the other way around. We have a database that has already been designed, and we are looking at using nHibernate. It would be nice to use a tool to generate the mappings and classes from the database, and then we could tweak/manipulate them to suit our tastes.
NHibernate Mapping Generator
You can use nhibernate with an existing database. It is a matter of writing the mapping files.
I also recommend using Fluent Nhibernate...I started using this after this community recommended it..
Look at subsonic as well if you do not like maintenance of mappings.