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


ADVERTISEMENT

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

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

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

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

.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

.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

Concurrency Handle Is Part Of The Software Developer Or Database Developer?

Jul 23, 2009

In CRUD application development we have to face the issues with concurencies in Ids such as Generate and display UNique EmployeeIDs on forms. Currently i'm writting .DLL file that has a class that will handle concurrencies.

But i'm puzziled with the Question, is this concurrency handle is part of the software developer or Database developer?

View 9 Replies

VS 2010 Options View Control - Child Options?

Aug 20, 2011

I am in need of a form that shows various options, exactly like the Options in Visual Studio. Since there are so many options I too want them categorized, with a TreeView to the left taking care of showing the right category.The usual 'easy' approach here would be to just place a TreeView control on the form, add some nodes, and give those nodes a tag or key that corresponds to a panel or UserControl with the options for that category.Since there will be a lot of options however, this is not really feasible design-wise; the form would be cluttered with possibly 50 panels, all of which I would need to select and bring to front from time to time to add controls to them that represent the options.

So I decided to create a custom control that does exactly that. The control is very similar to my Wizard usercontrol, users can add OptionsPanels at design time, which inherit Panel and simply represent one panel of options. When they do, the panel is added to a container panel, and at the same time a TreeNode is added to a TreeView. The control uses a custom ControlDesigner to handle design-time clicks in the Treeview, selecting a different node would select and bring to front the corresponding panel, allowing the user to add the controls he wants.

Due to the design time support the problem of having 50 panels is no longer present, only one panel will be visible at a time and selecting the right panel is as simple as selecting the corresponding TreeNode, just as during run-time. Anyway, I got all this working, but only for a single 'level' of categories. As you can see in the Visual Studio options, there can be multiple levels of categories. For example, the Environment node has a bunch of children, where each child represents one 'options panel'. There can even be deeper nesting, see the Text Editor node for example.Let me begin by drawing out the basics of how my control works so far.

The main control is an OptionsView control, which contains a SplitContainer with a TreeView to the left and a OptionsPanelContainer to the right. The OptionsPanelContainer is merely a Panel to which only OptionsPanel controls can be added, and which raises events when this happens, as well as when OptionsPanels are removed from it. An OptionsPanel also inherits Panel, and these are the actual panels the users will see in the control, one for each option category.For now, each OptionsPanel has exactly one corresponding TreeNode (and vice versa). In the Visual Studio options, each 'parent' category usually has a 'General' node as the first child, and the parent and this General node show the same option panel, but I am ignoring that for the moment.

The OptionsView control has a property Panels that returns the ControlCollection (Controls property) of the OptionsPanelContainer (in other words: it returns a collection of OptionsPanels that are in this container panel).

vb.net
<Editor(GetType(Designers.OptionsPanelCollectionEditor), GetType(UITypeEditor))> _ <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public ReadOnly Property Panels As Control.ControlCollection Get Return Me.PanelContainer.Controls End Get End Property

A custom CollectionEditor for this property takes care of the designer: even though the property type is ControlCollection, the CollectionEditor knows it should create instances of the OptionsPanel control instead of just Controls.When it does this, a corresponding TreeNode is also created and its Tag property is set to the OptionsPanel. Vice versa, the Node property of the OptionsPanel is set to the node. Hence the node and panel both know their corresponding object.

vb.net
Public Class OptionsPanelCollectionEditor Inherits System.ComponentModel.Design.CollectionEditor Public Sub New(type As Type) MyBase.New(type) End Sub Protected Overrides Function CreateCollectionItemType() As System.Type

[code]....

So far so good, this all works fine. I can add Panels via the designer and when I do a new TreeNode appears in the TreeView. I can select this node and the panel becomes visible (comes to the front).Now, I am a little stuck. How do I implement child option panels? And more importantly: how do I let the user add child panels?The most logical choice I think is to let each OptionsPanel have a property (ChildPanels or something) that returns the child OptionsPanels for that panel. Once the user selects an OptionsPanel then, he can look in the property grid to find its ChildPanels property and add child panels to that.

There is a problem though: what would this property return? It must return a ControlCollection of some container (this is, I think, a requirement for the designer features to work, otherwise panels are not added to the Form.Designer.vb file). But there is no container. I cannot add them to the OptionsPanel itself, that would make no sense because the parent OptionsPanel has its own set of controls (the options itself...), there cannot be another (fully docked) Panel on top of those obviously.The container of the main OptionsView then? That is not an option either, its Controls collection holds ALL OptionsPanels, not just the children of the selected panel. I cannot 'select' only the right panels either, that would require me to return a new instance of ControlCollection, it would be impossible to return the actual ControlsCollection that holds merely a small selection of its controls.

View 5 Replies

Or Keyword - Does Options = Options Or Does It Set RegexOptions.none

Feb 28, 2010

With the following piece of code

CODE:

The Or keyword is confusing me. So in the above example which variable gets set. Does options = options or does it set RegexOptions.none.

View 9 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

Hypothetical Controls - Options Checked As Enabled In FrmConfig Effects - Controls (like Buttons/menu Options) Are Enabled In FrmMain

Nov 26, 2010

As i'm learning more and more about developing ive just got my head around creating classes and modules, i started wondering about something to do with configuration of applications where deployment is in a more diverse environment say in a company where different branches dont need access to all parts of a program, so i thought id throw the question out there in a basic sense and get some feedback. so i can go off and do some more reading and learning.

So the scenario in my head is like this.

So we have for arguments sake FrmConfig which is the master configuration form, then we have FrmMain which is the root menu our application general user interfaces with. So here based on what options are checked as enabled in FrmConfig effects what controls (like buttons/menu options) are enabled in FrmMain.

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

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

What's The Best Way For A C# Developer To Learn VB?

Mar 26, 2009

I'm a C# programmer who needs to pick up some VB. The syntax differences are easy enough to figure out, but there are other things I'll need more of a tutorial on. For example, VB's "strict" mode in Visual Studio is something essential to me, but something I wouldn't have learned just by comparing language syntax. Any recommendations on how to pick up VB quickly, yet thoroughly? I can't stand to work through a 1000 page book introducing VB to novices.

View 10 Replies

Binding NHibernate Proxy Objects To A DataGridView?

Jan 22, 2012

I am attempting to bind objects pulled from an NHibernate session to a DataGridView and am having problems.I have a single session in which I fetch all of my "look-up" items that are bound to a combobox column, and then I query for the objects themselves. omehow, this still results in proxy child objects on the main objects. I have even changed the mapping of the look-up items to eager fetch, but I still get proxies somehow.Here is how I am fetching the objects:

Dim _makes As IList(Of Make) = session.QueryOver(Of Make).List
Dim _models As IList(Of Model) = session.QueryOver(Of Model).List
Dim _cars as IList(of Car) = session.QueryOver(of Car).List

[code].....

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

How To Persist Anonymous Types Instances Through NHibernate

Feb 12, 2010

Instinctively, I would say that this is impossible, as NHibernate needs to know some mapping information on how to persist a given type. Thus, I encountered some situations in which I could use such a feature. For instance, through a named query or something like so. On the other hand, using a named query would require me to make an addition to the configuration file.

Let's suppose we have an application interacting with some underlying datastore. This datastore is configured through the NHibernate configuration file. Then, I wish to have NHibernate load only a subset of an entity properties, from another subsystem to which my application shouldn't need to interact much, so it is not worthy to define classes for this system, as I only need a fraction of this alien system's information, let's say three out of thirty-two data columns. For that matter, if I chose to load only those three columns let's say for performance concerns, I would then use an anonymous type, perform the required action onto this information, then persist it back to the datastore. Now, it wouldn't be of much interest to do so if I only had one entity to get loaded from the datastore, so let's say I have about 75,000 rows to load into my process. I then shall consider this subset option very seriously!

What strategy should you choose in such situation, if you needed to persist these changes to a subset only of this entity's properties?FYI: I am asking because I must write specific rules of usage with NHibernate, such rules that even a beginner developer would even be able to use it without knowing too much about NHibernate, but only following the rules and guidance of the technical documents I have to produce.

View 1 Replies







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