Mapping Custom GUID With Fluent NHibernate

Dec 6, 2011

I am using Fluent NHibernate to map an Oracle database. It is a legacy database so I cant really change everything I want.There is a GUID field, but the keys are still composite (I will change this as soon as I can so that the keys are not composite, but I cant do it right now). The GUID is a VARCHAR2 field with this layout: 551608b1-275d-49f6-9561-44d01aacf23f. The GUID is not added by a sequence in Oracle, but inserted from code (C# or VB.net)[code]Is the problem that I dont use a sequence to generate my GUID? How can I overcome this?

View 1 Replies


ADVERTISEMENT

Fluent NHibernate Not Mapping Child Rows To A Collection Property (DB2 Database)

Nov 4, 2011

The tables described herein both utilize composite keys. I have a parent table that stores eligibility information per "case". The child table stores eligibility information regarding each individual associated with the case. The child records are differentiated by pin number to make them unique in the child table only.

I am using NHibernate v3.1 with Fluent NHibernate v1.2, both acquired via NuGet packages. The entities are mapped in using the Fluent NHibernate auto-mapper functionality. Any custom mapping is done in the mapping override method for each entity.

Another thing to know is that these tables do not have a "primary key" defined in DB2. They only have "unique keys", which are what you see in the composite key definition below (see code).

T0026_AG_ELIG is the name of the parent table and the corresponding POCO class.
T0265_AG_IN_ELIG is the name of the child table and the corresponding POCO class.

Problem:

The problem is that when I execute the query, all the data is queried, the parent record is successfully mapped to the class, but the returned child rows do not map into the collection on the parent class. NHibernate does generate the queries for the parent and child data. When I execute my own query against the database, the correct data for the conditions does come back. For some reason, the child records are just not being bound to the property on the parent (T0026) class.

Question:

What do I need to do to get the multiple rows coming back from T0265_AG_IN_ELIG to map to their corresponding class and load properly into the specified collection property on the parent class (T0026_AG_ELIG)?

Collection Property of Parent (T0026_AG_ELIG):

Public Overridable Property IndividualEligibilityRecords As IList(Of T0265_AG_IN_ELIG)
Mapping Override for Parent (T0026_AG_ELIG):
mapping.CompositeId() _

[Code].....

View 2 Replies

VS 2008 .NET For NHibernate And Fluent NHibernate?

Oct 26, 2010

I would like to ask if you can use VB.NET for NHibernate and Fluent Nhibernate?I have searched the web, but I can't seem to get a detailed or explicit statement that tells that one can use VB.NET for NHibernate and with Fluent.

Many of the samples in the NHibernate site are made in C#. That's why I was wondering if I can't use VB.NET when using NHibernate.

View 2 Replies

.net - Fluent NHibernate Duplicate Columns?

Dec 28, 2011

I am having some redundant primary key issues.I have an Item which contains many reports. I have mapped them as shown below. I can do Session.QueryOver(Of Item).List and there are no extra columns generated. I can also do Session.QueryOver(Of Report).List and there are no extra columns generated.

However, once I try to traverse the relationship from Item to Reports, I get the SQL query shown below. Can anyone tell me why?

[Code]...

View 2 Replies

C# - Executing Sql Statements With Fluent NHibernate

May 12, 2009

Basically I want to be able to do this:

session.ExecuteSql("...");

I don't need it to map to any entities or return any values.

View 1 Replies

Ignoring Properties In Fluent NHibernate With (2.0)?

Jul 29, 2010

Because there is so little information about VB.Net and (Fluent) NHibernate to be found, I decided to write this question to all other developers finding themselves looking for more information.On of the things i had to struggle with was how to Ignore properties in NHibernate.The reason i had to ignore properties was because we used a Webserivce which cannot serialize Interface classes (ILists). Which are used a lot with NHibernate.

View 1 Replies

Options Are Available For A Developer When Using Fluent NHibernate?

Jul 9, 2010

I've been using c# for the past year and I enjoy the power you get with Fluent NHibernate. One question that I get from friends is "nice but how can vb.net programmers use this?"So for example- the below is a c# mapping class. How would someone do this with vb.net?

public class PostMap : ClassMap<post>
{
public PostMap()
{
Table("Posts");

[Code]...

View 1 Replies

Fluent NHibernate To Ignore Specific Properties Without Automapping?

Dec 21, 2011

I am using Fluent NHibernate to map out an existing database. For this reason - automapping isn't an option for me.How do I tell NHibernate not to map certain properties? Many of them are read-only, and the others do not need to be persisted for other reasons.

I am writing this in VB.Net.I get the typical error message:"The following types may not be used as proxies should be 'public/protected virtual' or 'protected internal virtual'"I have purposely not made my objects Overridable (equivalent to virtual in C#) because I do not want NHibernate to touch them.

View 1 Replies

C# - Nhibernate Mapping Of System.Drawing.Image?

Oct 5, 2010

Question: I get an exception serializing this class to a nHibernate xml file ({"Could not determine type for: System.Drawing.Image, System.Drawing, for columns:NHibernate.Mapping.Column(Settings)"}).

using System;
using System.Collections.Generic;
using System.Text;

[code].....

View 3 Replies

NHibernate Mapping SQL-VIEW Without Unique Identifier?

Oct 13, 2011

I have a read-only mssql-view, and I want to map it to nhibernate (using hbm.xml files). The view is a select that joins two tables. For give an abstract-insight, the select is something like this:

SELECT A.Id As A_ID, B.Id As B_ID,
A.AttributeA, B.AttributeB,
FROM A INNER JOIN B ON
A.Id = B.RootID

It's a one-to-many relationship between A and B (B entries are dependant/leafs of A entries).

I'm using nhibernate's hbm.xml files, and I can't make it to work. I'd gladly appreciate if someone can enlight me of the kind of XML that I have to use, I guess that as my view has no ID, I have to create a composite-nhibernate id (wich will be the ids os A and B together) but I couldn't make it to work. Also the view is READ ONLY so I think that should make the solution easier.

View 2 Replies

Nhibernate - What Would Be The Equivalent .NET Code For This C# FluentNHibernate Component Mapping

Feb 4, 2010

I'm a C# programmer constrained to write VB.NET code.While exploring NHibernate further for my current client, I encountered FluentNHibernate, which I find real attractive.But now, I wonder how to "translate" this C# code for component mapping into VB.NET code:

Component(x => x.Address, m =>
{
m.Map(x => x.Number);
m.Map(x => x.Street);

[code]....

what I miss is how to continue with the brackets in VB.NET, since there's no Begin End keywords or so.

EDIT 1: Following Mr. JaredPar instructions, I figured that his solution might work. If we take the time to read his answer, we may notice that we both don't know what the MType is within his solution. I might have found out that the MType is:

FluentNHibernate.Mapping.ComponentPart(Of TComponent)

Thus, TComponent is, from my understanding, an anonymous type that I shall parameter to use. From this point of view, since I wish to map the properties of my Address object, replacing TComponent in my help method signature seems not to work.

Private Sub MapAdresseHelper(Of Adresse)(ByVal a As FluentNHibernate.Mapping.ComponentPart(Of Adresse))
a.Map(Function(m) m.Number)
a.Map(Function(m) m.Street).Length(50)

[code]...

The error I get is that my Address class doesn't have a property member named Street, for instance. It sees my Address type, it recognizes it, but it seems buggy somehow. I guess VBNET is poorly designed for lambda expressions and is less evolved than C#?

View 3 Replies

.net Project With C# Fluent NHibernate Mappings Project?

Sep 30, 2010

Having successfully tried out nHibernate, I would now like to try using Fluent for mapping. My main project is in vb.net but I would really like to use c# for the mappings since the lambda expression capability makes it much cleaner. Can you have a separate project/assembly for your mapping files without creating a circular dependency with domain objects?

View 2 Replies

Project With C# Fluent NHibernate Mappings Project

Dec 2, 2009

Having successfully tried out nHibernate, I would now like to try using Fluent for mapping. My main project is in vb.net but I would really like to use c# for the mappings since the lambda expression capability makes it much cleaner. Can you have a separate project/assembly for your mapping files without creating a circular dependency with domain objects?

View 1 Replies

Accepting Multiple Parameters In MVC 4 Web API Controller And Mapping To Custom Methods?

Jun 25, 2012

I'm trying to implement a Web API project that exposes some models. However, the way the model is retrieved isn't very RESTful. 1.Instead of having just one ID, it has a combination of 4 different ones to populate the model data by running a stored proc on the server.Dim balance as New BalanceSheet(uid, mid, eid, fid)The snippet above will use uid, mid, eid, fid to retrieve the correct record from the database.

View 1 Replies

.net - NHIbernate NHibernate Attempts To Execute A Database Update During CreateQuery Execution?

Mar 10, 2010

Basically, I wish to fetch a filtered set of objects from the database (Oracle 9.2) based on the id property of the object PsalertsEvent. The code being executed is:

Public Overloads Function GetAll(ByVal laterThan As Long, ByVal filteredPsalertsEvents As IList) As IList Implements IPsalertsEventRepo.GetAll
'Get all psalerts events with an ID greater then the specified laterThan parameter
filteredPsalertsEvents = MyBase.NHibernateSession.CreateQuery("from PsalertsEvent p where p.id > " & laterThan).List

[Code]...

View 2 Replies

MS Entity Framework VS NHibernate And Its Derived Contribs (FluentNHibernate, Linq For NHibernate)?

Feb 4, 2010

I just read this article about the Entity Framework 4 (actually version 2).Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate.NHibernate and its current contributions of FluentNHibernate and Linq for NHibernate by Ayende RahienMy feeling is that Microsoft is solely trying to gain terrain it has lost in favor of NHibernate when the 2nd version of NHibernate came out.Nevertheless, my concerns are the followings (not in particular order):Will EF4 tend to be less XML-verbose?Will EF4 be compatible with other underlying datastore than just SQL Server?What are the greatest benefits of going with EF4 instead of FluentNHibernate or NHibernate itself.

NHibernate is a great tool, I guess everyone agrees. Due to its predecessor Hibernate, we may easily find documentions and tutorials and sample applications to get acquainted with it. This is not the case for FluentNHibernate. Particularly as per the project I'm working on right now which demands that I investigate further about NHibernate and its options (FluentNHibernate for instance) in order to document the rules of usage and the best practices of NHibernat and FluentNHibernate technology. Thus, being handcuffed with VB.NET, being a C-Style developer, I can't find some syntax equivalencies in VB.NET for the examples provided, though I made I way so far

View 3 Replies

GUID In Registry - Get The Program To Preform This Task On Another Computer As Their GUID Will Be Different?

Feb 26, 2012

im workin on a task that will get the current computers Default Gatway, So i chose the easiest option, using the Registry, in most cases i find this with no problem at all, here's the code im using right now,

Public sHost As String = My.Computer.Registry.GetValue _
("HKEY_LOCAL_MACHINESYSTEMControlSet001servicesTcpipParametersInterfaces THE GUID NEEDED HERE ", "DhcpServer", Nothing)

Which works fine, if i put My GUID in where i've stated in above code, I get the right value ect..., no what i was woundering is how would i get the program to preform this task on another Computer as their GUID will be diffrent, if their away i can do this with simplicity?

View 3 Replies

Using Type Inference With Fluent Interfaces?

Feb 17, 2012

I have a class /interface hierarchy. On the interface side I have

IQuery
ISelect (inherits IQuery)
IUpdate (inherits IQuery)

[code].....

View 2 Replies

VB - Entity Framework 4.1: Describe Relationship Into The DbContext Definition Using A Fluent Code First Approach?

Dec 5, 2011

I have in my database a table (AccessControl) that describes a sort of users "access control list" for the informations contained in the table Customers and other tables.Example: the entity CUSTOMER is marked by the EntityId #1. If a user belongs to the department #6, he can access the records of customer #16 and #31, but he can't for #14, that can viewed by user in department #3:

[code]...

How can I describe this relationship into the DbContext definition using a fluent Code First approach?

View 1 Replies

How To Use QueryOver With NHibernate

Feb 7, 2012

how to use nHibernate with Vb.net using all the examples online(which are in C#) to learn. Which has been fine for the basics, but now I'm trying to learn how to use QueryOver's JoinAlias, and going from C# to VB.net is difficult. I've been using this page's answer as a reference, but I'm still having trouble converting an example like that to Vb.net.

View 1 Replies

.net - Can't Get Linq To NHibernate To Work?

Nov 22, 2009

I'm struggling with getting Linq To NHibernate to work.I have referenced NHibernate, NHibernate.Linq and NHibernate.ByteCode.Castle . Also I have all other dependencies in the same folder.

Code / Error message:

Public Function GetProjectsByName(ByVal ProjectName As String) As List(Of Project)
Return (From x In _session.Linq(Of Project)() Where x.Name.Equals(Project))

End Function[code]....

... tells me that the LINQ extensions aren't loaded. Using NHibernate.Linq seems to be made in a way that it's incredibly easy to use, hence there are no tutorials on how to set it up. (Or at least I couldn't find any).

View 1 Replies

Best Way To Use NHibernate With The Repository Model

Mar 16, 2009

I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I use NHibernate to do the work on my business entities. For example:

[code]...

However, on my User class I have some properties and collections of other objects that ideally I'd like to be lazy loaded. But of course, the ISession is created and disposed within the repository, which I guess is why, outside of that, when I try to access those properties I get a "Could not initialize proxy - no Session" error.Is my only option then to disable lazy loading when using repositories? Or is it possible (or just foolish) to somehow get the session into scope in the business layer?I do like the repository model, and NHibernate is growing on me (after lots of initial frustration trying to make it work), so what's the best way you gurus have found of using them together?

View 1 Replies

NHibernate HQL Dynamic Instantiation?

Jun 27, 2012

I can't find what's going on with the following nHibernate HQL.

here's my VB.Net code:
Return _Session.GetNamedQuery("PersonAnthroSummary").SetInt32(0, 2).UniqueResult()
My Named Query:

[code].....

View 2 Replies

NHibernate Select Query?

Mar 16, 2009

I have an ado.net statement I want to convert to use NHibernate:

Dim sql As New StringBuilder()
sql.AppendLine("SELECT r.RoleId, r.RoleName ")
sql.AppendLine("FROM dbo.aspnet_Roles r ")

[code]...

View 1 Replies

Is A GUID Really Unique

Jan 8, 2010

Is GUID really unique? I have a webservice that the client application connects to, which generates a GUID. I know GUID are generated using the mac adress of the NIC. Is the NIC in the webservice server used or the client NIC?

View 1 Replies

Specify GUID For Event?

Aug 27, 2011

I need to specify a GUID for each event declared in my class, to be able to generate a manifest for it.

Right now i'm decorating the class with the following:

ComClass("AB849263-E1F7-466B-9BAC-828E67F2871D", "EB2AB5A4-D3AD-4C01-81FB-A73AB0B3848C", "6623B1F2-2D4E-4974-AE51-369F65D47F69")

However when i use the MT tool to generate the manifest, i'm greeted with : "mt.exe : genman warning G81010014: Explicit guid not defined for type NetTest.NetClass+TestEventHandler."

View 5 Replies

Used To VB6 Key Mapping?

Jul 26, 2011

I ALWAYS USED WITH VB6 F8 KEY TO DEBUG ON WIN 7 ITS MAPPED TO VOL CNTRL

View 4 Replies

C# - NHibernate Entity Code Conversion From #C?

Jan 12, 2011

I am starting on the NHibernate world and i am experimenting with the NHibernate CookBook
recipes, i am trying to set a base entity class for my entities and this is the C# code for this. I would like to know whats the VB.NET version so i can implement it in my sample project

View 3 Replies

Error Building SessionFactory In NHibernate?

Apr 28, 2009

I am getting an "ArgumentOutOfRangeException" on parameter index whenever I try to instantiate a session factory in nHibernate. The error comes from a procedure deep in the bowels of nHibernate. This is on a fresh project with a pretty simple three tier architecture. The data layer maps the nHibernate classes to simple interfaces which are implemented by the business layer.Currently there is only one interface set and mapping file being used by nHibernate. Hopefully my issue is easy to spot.

Here is the function where I build the sessionFactory.

Private Shared Function SessionFactory() As ISessionFactory
If _sessionFactory Is Nothing Then
Dim config As New NHibernate.Cfg.Configuration
config.Configure()

[code]....

Edit2: When I remove the discriminator I no longer get this error. Am I not doing that right?

Edit 3: When I download the source code for nHibernate, build it on my own, link to it's debug output and run it, I get a completely different error about ProxyFactoryFactory not being configured.

View 1 Replies

NHibernate & SQLite = [Class] Is Not Mapped?

Dec 21, 2010

Well i have been fighting with this for a little bit now, and i can't seem to find a solution for something it should be really simple. I got a class ( really simple class ) i got the hbm.xml ( SET AS EMBEDDED RESOURCE ) i got the config file set for SQLite but i still get the [Class] Is not mapped.Here is where the error comes up, when i run this:

Public Sub LoadCentersFromDatabase()
Try
Dim session As ISession = OpenSession()
Dim query As IQuery = session.CreateQuery("from Center")

[code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved