Questions tagged [fluent-nhibernate]
Fluent NHibernate lets you write NHibernate mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.
5,484
questions
0
votes
0
answers
7
views
Fluent nhibernate BuildSessionFactory with Microsoft.Data.Sqlite is not Working
Trying to establish session factory on Microsoft.Data.Sqlite with fluent nhibernate. All references are added and are available in the bin folder on runtime.
var sessionFactory = Fluently.Configure()
...
0
votes
1
answer
28
views
Map a HasMany relationship without any key column whatsoever - Where() only
Conceptually I want to map a collection like this:
HasMany(x => x.Children).Where("some_column_name='foo'");
The default mode of HasMany() requires me to provide a KeyColumn which should ...
0
votes
1
answer
22
views
Select data from a sub-select
This is what I want to accomplish using NHibernate QueryOver:
SELECT TOP 10 * from
(SELECT aColumn, min(WorkingDay) as d
FROM aTable
GROUP BY aColumn) ...
0
votes
0
answers
23
views
How to use fluent nHibernate from an ArcGIS Pro 3.1 AddIn with C#?
I am programming a ArcGIS Pro 3.1 AddIn with C#.
I try to initialize a fluent nHibernate connection:
public ISessionFactory CreateSessionFactory()
{
Action<MappingConfiguration> mappings = m ...
0
votes
0
answers
17
views
Fluent Nhibernate HasMany Duplicate Insert Problem
I Have Duplicate Insert Problem. When i try insert duplicate rows
public class CostRegister : Entity<int>
{
public virtual IList<CostDocumentRegister.CostDocumentRegister> ...
0
votes
0
answers
40
views
NHibernate Queries with Common Table Expression
I have an SQL Server query of the kind:
WITH MostRecentToday AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY ItemGuid ORDER BY Version DESC) AS rn
FROM Items
WHERE Cast(Timestamp As date) = '...
0
votes
1
answer
28
views
Why does fluent nHibernate throw a NotSupportedException?
I use this query to search for a name in a SQL Server database via fluent nHibernate:
var content = (from person in DBSession.Query<Person>()
where
(...
0
votes
1
answer
127
views
Error while adding second level cache in Nhibernate configuration .Net Core 6
I have migrated my legacy Asp.Net project to a Asp.Net Core 6 solution.
I try to build the NHibernate session factory by adding a second level cache provider ('CoreDistributedCacheProvider') but I am ...
0
votes
1
answer
54
views
nhibernate transaction sometimes does not insert all records
After doing more research and listening to advice here I have been able to get closer to figuring out my issue. The NHibernate issue that I am having deals with a transaction and it has only been ...
0
votes
1
answer
15
views
Why does Fluent nHibernate not set Id of child object when using SaveOrUpdate?
Why does Fluent nHibernate not set Id of child object when using SaveOrUpdate?
I got the following fluent nHibernate domain and mapping classes (reduced for this question):
public class Error
{
...
0
votes
1
answer
82
views
nHIbernate query with conditional join
I'm trying to get an nHibernate query to work without success. Here is my data structure:
public class Permission {
public Guid Id {get; set;}
public string Name {get; set;}
}
public class ...
0
votes
0
answers
27
views
Fluent Nhibernate with oracle full text search Contains
Im using Nhibernate with linq query and need to use full text search with 'CONTAINS' like
CONTAINS(text, 'oracle', 1) > 0;
As i seen there is no solutions for generate this keyword with linq, there ...
0
votes
1
answer
20
views
FluentNHibernate exception when there are slash in the default value
I have been trying to map a string value using FulentNHibernate like below.
Map(x => x.FilePath).Length(500).Not.Nullable().Default(@"C:\Program Files\server\data\conf\groups.txt");
But ...
0
votes
1
answer
25
views
Nhibernate map one column to two tables based on type
Is it possible to create nhiberante mapping for this sql structure (so base on CompanyType it links CompanyId to either CompanyTypeA or CompanyTypeB):
----
UserTable
----
Id (int)
CompanyId (int)
...
0
votes
0
answers
161
views
Version number in Entity Framework Core equivalent to NHibernate
In NHibernate when we are mapping an entity, we map version number like this:
Version(x => x.VersionNumber);
As a result, VersionNumber gets added with default value of 1 and with each update of ...
0
votes
1
answer
88
views
NHibernate and SQL Server Temporal Tables
I am using Fluent NHibernate to query data stored in a SQL Server temporal table. All I really want to do is to run a query such as
SELECT * FROM [MyDB].[dbo].[MyTable] for system_time as of '2022-12-...
0
votes
1
answer
84
views
How to map an enum as a foreign key in (Fluent) NHibernate?
How do I map an enum property as an integer foreign key in (Fluent) NHibernate?
The enum property serves as a type field which is an integer in the database, but it also needs to be a foreign key to a ...
0
votes
0
answers
43
views
Why I dont get an exception when fluent nHibernate fails to create table?
I use fluent nHibernate to connect to a SQL Server database. So this is my domain class:
public class Option
{
public virtual long Id { get; set; }
public virtual string User { get; set; }
...
0
votes
0
answers
28
views
Fluent NHibernate foreign key is null
I have two tables - master-detail with relation one-to-many.
Here are definitions and mappings:
public class Employee
{
public virtual int Id { get; set; }
public virtual string FirstName { ...
0
votes
0
answers
29
views
Fluently with NHibernate: reference other row in table by "parent_id" but return actual entity, not the id?
I was wondering if this is possible with Fluently in NHibernate. The scenario:
I have an entity looking something like this:
public class PairedEntity
{
public virtual int Id { get; set; }
...
0
votes
0
answers
69
views
NHibernate session.saveOrUpdate takes a long time
I have the below mapping of data, everything is mapped correctly for each mode
public DataMap()
{
Id(x => x.Id).GeneratedBy.Identity().UnsavedValue(0);
Map(x => x.Name).Not....
0
votes
0
answers
204
views
Fluent NHibernate mapping to view and table
I have a situation where I would like to write data to both an Entity table and an Entity view.
We are migrating the source of truth for some data in a table from a single multi-tenant database to ...
0
votes
1
answer
60
views
fluent NHibernate not saving the foreign key in HasMany. The column remains null
I am struggling to have the Foreign Keys in my mappings.
My Model looks like this:
public class Accountant: Entity
{
public virtual string Name { get; set; }
public virtual IList&...
-1
votes
1
answer
28
views
Can I use NHibernate.Cfg.Configuration in Fluent-NHibernate when building a session factory?
I want to use the NHibernate configuration for FluentNhibernate when building a session.
This how I am constructing my factory session:
lock (_factorylock)
{
if (_factory ==...
0
votes
1
answer
50
views
FluentNHibernate.Cfg.FluentConfigurationException NHiberNate
I get an error like this when writing unit test
My product class is like this. I added virtual.
My map is like this.
SqlServerHelper like this.
I am using vs code 2022. I'm developing with Net 6.0 ...
1
vote
1
answer
102
views
Slow query in MS-SQL + Fluent NHibernate
TL;DR: A query using wildcards/like takes four times longer to complete in Fluent NHibernate than executing exactly the same query using Management Studio. This only happens in MS-SQL, while Postgres ...
0
votes
1
answer
115
views
FluentNhibernate - Handle query that refers to a null reference
I tested NHibernate in .net Core and in .Net framework and it seems that requesting a null reference is managed and does not raise a null reference for example by retrieving: x.Property_A.Property_B ...
-1
votes
1
answer
46
views
Fluent NHibernate adding Where() in mapping constructor doesn't work with subquery
I have this entity mapping:
public class ExpedienteNnaMap : ClassMap<ExpedienteNna>
{
public ExpedienteNnaMap()
{
Table("personasexpediente");
...
0
votes
0
answers
42
views
Calling stored procedure on Inherited class in [Fluent] NHibernate without discriminators
I have a working Fluent project with some inherited tables
class Base { int BaseId }
class Derived : Base {}
class Derived2 : Base {}
class BaseMap : ClassMap<Base> { ID BaseId ); }
class ...
2
votes
1
answer
40
views
Inheritance Mapping Fluent NHibernate results in unnecessary joins
The issue is when selecting directly on the base model the generated SQL performs an left outer select on the subclasses.
Basemodel.
public class Node
{
public virtual int ID {get;set;}
public ...
0
votes
1
answer
44
views
How to run an NHibernate SQL Delete with a final SELECT reporting completion?
Description
For a project I'm working on, I'm creating a purge feature that deletes old data from this system's database.
I've found that, while my SQL works correctly when ran from SQL Studio, it ...
0
votes
1
answer
16
views
FluentNHibernate: how to map elements of a list
I have the following classes:
public abstract class AbstractGeometry : IGeometry
{
// something
}
public class CompositeGeometry : AbstractGeometry
{
IGeometry MainGeometry { get; set; }
...
0
votes
1
answer
93
views
How to map a collection of components as a set in fluent nhibernate
I want to map a collection of components on an entity. The component looks like this:
public class PermissionUserSetting
{
public virtual PermissionType PermissionType { get; set; }
public ...
0
votes
1
answer
45
views
How can I edit the EXISTS clause produced by NHibernate?
How can we override the usage of the HqlExists class for it's usage creating an EXISTS clause in a given NHibernate configuration/dialect?
The driver being used requires that only a single column be ...
0
votes
1
answer
74
views
Fluent Nhibernate Many to many with a pk and fk in one table
Hey i have the following mysql tables:
and i have the following maping classes:
public class WalletMap : ClassMap<Wallet>
{
public WalletMap()
{
Id(x => x....
0
votes
2
answers
159
views
Cannot insert the value NULL into on referenced object
I'm trying to add a new object with nHibernate, but for some reason it tries to update a field on a referenced object that hasn't been provided resulting in:
Cannot insert the value NULL into column '...
-1
votes
1
answer
126
views
Fluent NHibernate: How to map FK keys as properties in .NET Core version
we are using fluent API and I need to know how I can map it correctly so we can use ParentId instead of having to go through Parent entity. Is that possible? I know it can be done using EF Core so I ...
0
votes
1
answer
32
views
NHibernate: One-To-One-Relationship not correctly updating
I want to map two types, ConnectionProfile to ConnectionType. In my ConnectionProfile I have:
public virtual ConnectionType ConnectionType { get; set; }
in my ConnectionType I have:
public virtual ...
0
votes
1
answer
33
views
FluentNhibernate Map ValueObject
I have the following use case:
public class Object {
long Id
...
ISet<Tags> tags
}
public class Tag : IEquatable<Tag> {
string Label;
}
Object is an Aggregate Root and ...
1
vote
0
answers
388
views
How to share an image with text on instagram story on through flutter?
I am trying to share an image with text on instagram story through flutter and i have tried various plugins to share but every time i can only share an image but not text.How to do it? Please help.
...
0
votes
1
answer
62
views
How to check if there is a person in the database who has exactly two (or more) specific addresses? (QueryOver)
I want to check if there is a person in the database who has exactly two specific addresses.
My proper SQL query:
SELECT name, id FROM person
WHERE person.name = 'Kxxx' AND person.firstname = 'Axxx'
...
0
votes
0
answers
92
views
Fluent NHibernate Mapping multiple tables has relation and joined to each other
As you see the models have references as one to many. list of project is not mapped here. there are more than one project and the project has more than one role and the role has more than one ...
7
votes
1
answer
2k
views
could not create the driver from nhibernate.driver.sqlclientdriver, nhibernate, version=5.3.0.0, culture=neutral, publickeytoken=aa95f207798dfdb4
I faced the below error fluentNhibernate in .net 6 project but the same code is working in framework 4.8.
Error: could not create the driver from nhibernate.driver.sqlclientdriver, nhibernate, version=...
0
votes
1
answer
76
views
Fluently.Configure throws "Database was not configured through Database method" exception
I am trying to get an in-house application up and running for debugging and when I start the solution, it fails calling the Fluently.Configure() method. Digging into the exception, I see the potential ...
0
votes
0
answers
162
views
WPF and SQLite 'Value cannot be null. Parameter name: conn' on SchemaExport NHibernate.Tool.hbm2ddl.SchemaExport
WPF application allows users to generate SQLite databased. Randomly I'm getting error on creating database. I'm using fluent mapping.
Error as below. PontentialReasons is empty.
An invalid or ...
0
votes
1
answer
52
views
when tray to build flutter APK
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\LEGION\flutter_windows_2.2.3-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
What went wrong:
Execution ...
0
votes
0
answers
95
views
In a .NET application, how do you model this SQL relationship?
BACKGROUND TO THE DOMAIN
I have a .NET application with a SQL Server database underneath. Each customer has their own database.
In that database, I have a table called Label which is empty on new ...
0
votes
1
answer
37
views
How to use a WPF-Combo-Box with fluent nHibernate so its saves after the user changes the selection?
This is my ComboBox:
<ComboBox x:Name="comboBoxExchange" HorizontalAlignment="Left" Margin="167,162,0,0" VerticalAlignment="Top" Width="222" ...
0
votes
1
answer
76
views
How to force nHibernate to update referencing objects automaticly?
So I got two fluent nHibernate Tables in sqlite:
public class Product
{
public virtual long Id { get; set; }
public virtual Exchange Exchange { get; set; }
}
public class ProductMap : ...
0
votes
1
answer
17
views
Why does fluent Hibernate .Sum throws InvalidOperationException when used at an empty table?
I am using fluent Hibernate in C# to query a sqlite-database.
So this code works fine when there is at least one CashTransaction in my database.
public decimal? GetSum(ISession dbSession)
{
var ...