Search Results

Search found 744 results on 30 pages for 'fluent'.

Page 8/30 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Fluent NHibernate beginner problem: How to convert single column data to custom class?

    - by Stefan Ahlm
    I am very new to Fluent NHibernate and I have a problem that I cant find the answer to. I have a string column in my database table, containing a mathematical expression i.e: "10 + 15 * 5". On my entity I have a property that I call Formula and this returns a class that contains the mathematical "formula" (not as a string). I beleive this post http://intellect.dk/post/Implementing-custom-types-in-nHibernate.aspx explains how to solve it for NHibernate. But I am not sure... How do I get this working with Fluent NHibernate?

    Read the article

  • Is it possible to specify the name of the Index property to use for lists in a fluent nhibernate con

    - by Teevus
    When mapping a HasMany or HasManyToMany in fluent nhibernate, you can specify the column name to use for the list as a parameter to the AsList() method as follows: HasMany(c => c.Customers) .AsList(c => c.Column("PositionIndex")); I would prefer to be able to set this using a Fluent NHibernate convention (either a pre-existing one, or a custom one), especially since the default name appears to be "Index" which is a reserved word in MSSQL. I've tried using a custom convention implementing IHasManyConvention, but the instance parameter does not seem to contain the information about whether its a list, a bag, or a set, and also does not contain the column details for the index column. public void Apply(IOneToManyCollectionInstance instance) { } Any ideas?

    Read the article

  • Achieving more fluent movement

    - by Robin92
    I'm working on my first OpenGL 2D game and I've just locked the framerate of my game. However, the way objects move is far from satisfying: they tend to lag, which is shown in this video. I've thought how more fluent animation can be achieved and started getting segmentation faults due to accessing the same object by two different threads. I've tried the following threads' setting: Drawing, creating new objects Moving player, moving objects, deleting objects Currently my application uses this setting: Drawing, creating new objects, moving objects, deleting object Moving player Any ideas would be appreciated. EDIT: I've tried increasing the FPS limit but lags are noticeable even at 200 fps.

    Read the article

  • How do I use Fluent NHibernate with .NET 4.0?

    - by Tomas Lycken
    I want to learn to use Fluent NHibernate, and I'm working in VS2010 Beta2, compiling against .NET 4, but I'm experiencing some problems. Summary My main problem (at the moment) is that the namespace FluentNHibernate isn't available even though I've imported all the .dll assemblies mentioned in this guide. This is what I've done: 1. I downloaded the Fluent NHibernate source from here, extracted the .zip and opened the solution in VS. A dialog asked me if I wanted to convert the solution to a VS2010 solution, so I did. 2. I then went into each project's properties and configured all of them to compile for .NET 4, and built the entire solution. 3. I copied all the .dll files from /bin/Debug/ in the FluentNHibernate to a new folder on my local hard drive. 4. In my example project, I referenced FluentNHibernate.dll and NHibernate.dll from the new folder. This is my problem: If I right-click on FluentNHibernate in the References list and select "View in Object Browser...", it shows up correctly. Now, when I try to create a mapping class, I can't import FluentNHibernate. This code: using FluentNHibernate.Mapping; namespace FluentNHExample.Mappings { } generates an error on the using statement, saying The type or namespace 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?). The FluentNHibernate assembly is still in the list of References of my project, but if I try to browse the assembly in Object Browser again, it can't be found. What is causing this?

    Read the article

  • How to map IDictionary<string, object> in Fluent NHibernate?

    - by user298221
    I am looking to persist user preferences into a collection of name value pairs, where the value may be an int, bool, or string. There are a few ways to skin this cat, but the most convenient method I can think of is something like this: public class User { public virtual IDictionary<string, object> Preferences { get; set; } } with its usage as: user.Preferences["preference1"] = "some value"; user.Preferences["preference2"] = 10; user.Preferences["preference3"] = true; var pref = (int)user.Preferences["preference2"]; I'm not sure how to map this in Fluent NHibernate, though I do think it is possible. Generally, you would map a simpler Dictionary<string, string> as: HasMany(x => x.Preferences) .Table("Preferences") .AsMap("preferenceName") .Element("preferenceValue"); But with a type of 'object', NHibernate doesn't know how to deal with it. I imagine a custom UserType could be created that breaks an 'object' down to a string representing its Type and a string representing the value. We would have a table that looks kind of like this: Table Preferences userId (int) preferenceName (varchar) preferenceValue (varchar) preferenceValueType (varchar) and the hibernate mapping would like this: <map name="Preferences" table="Preferences"> <key column="userId"></key> <index column="preferenceName" type="String" /> <element type="ObjectAsStringUserType, Assembly"> <column name="preferenceValue" /> <column name="preferenceValueType"/> </element> </map> I'm not sure how you would map this in Fluent NHibernate. Maybe there's a better way to do this, or maybe I should just suck it up and use IDictionary<string, string>. Any ideas?

    Read the article

  • Persisting simple tree with (Fluent-)NHibernate leads to System.InvalidCastException

    - by fudge
    Hi there, there seems to be a problem with recursive data structures and (Fluent-)NHibernate or its just me, being a complete moron... here's the tree: public class SimpleNode { public SimpleNode () { this.Children = new List<SimpleNode> (); } public virtual SimpleNode Parent { get; private set; } public virtual List<SimpleNode> Children { get; private set; } public virtual void setParent (SimpleNode parent) { parent.AddChild (this); Parent = parent; } public virtual void AddChild (SimpleNode child) { this.Children.Add (child); } public virtual void AddChildren (IEnumerable<SimpleNode> children) { foreach (var child in children) { AddChild (child); } } } the mapping: public class SimpleNodeEntity : ClassMap<SimpleNode> { public SimpleNodeEntity () { Id (x => x.Id); References (x => x.Parent).Nullable (); HasMany (x => x.Children).Not.LazyLoad ().Inverse ().Cascade.All ().KeyNullable (); } } now, whenever I try to save a node, I get this: System.InvalidCastException: Cannot cast from source type to destination type. at (wrapper dynamic-method) SimpleNode. (object,object[],NHibernate.Bytecode.Lightweight.SetterCallback) at NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues (object,object[]) at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer (object,object[]) My setup: Mono 2.8.1 (on OSX), NHibernate 2.1.2, FluentNHibernate 1.1.0

    Read the article

  • How can I map one to one relationship in Fluent NHibernate. I have tried everything else

    - by RM
    I have this table structure and would like to map it using Fluent Hibernate (subclass if possible). I cannot change the structure because the database has too many records and might cause major applications rework. It would be easier if the Id from Party table was a foreign key in person and organization table, but in the particular scenario the database has person and organization key as a foreign key in party table. Any help would be great. Party table Id PersonId OrganizationId Person table Id FName LName Organization table Id OrgName OrgDescription

    Read the article

  • In NHibernate (Fluent), How do you map a property on referenced object into parent object?

    - by JChristian
    I want to map the Name column from the Child table into the Parent object. How do you do this (using Fluent NHibernate)? public class Parent { public int Key { get; set; } public string ChildName { get; set; } } Tables +--------------+ +------------------+ | Parent | | Child | +--------------+ +------------------+ | Key INT | +--->| Key INT | | ChildKey INT |-----+ | Name VARCHAR(20) | +--------------+ +------------------+

    Read the article

  • Fluent NHibernate OptimisticLock.None() causes "The string 'none' is not a valid Boolean value."

    - by David Thomas Garcia
    I'm using the following mapping: public class LoadMap : IAutoMappingOverride<Load> { public void Override(AutoMapping<Load> mapping) { mapping.HasMany(x => x.Bids).OptimisticLock.None(); mapping.Version(x => x.Version); } } But when I try to create the session I get the following exception: [FormatException: The string 'none' is not a valid Boolean value.] [XmlSchemaValidationException: The 'optimistic-lock' attribute is invalid - The value 'none' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:boolean' - The string 'none' is not a valid Boolean value.] I'm using NHibernate 2.1.2.4000 and I was using Fluent NHibernate 1.0RTM, but tried the latest build 636 just to be sure this isn't something that was fixed recently or something. As a side note, in case I'm doing this all wrong, I would like to be able to make changes to the .Bids list without incrementing Version. I saw an example on Ayende's blog that did what I wanted with properties.

    Read the article

  • Can Fluent nhibernate's automapper be configured to handle private readonly backing fields?

    - by Mark Rogers
    I like private readonly backing fields because some objects are mostly read-only after creation, and for collections, which rarely need to be set wholesale (instead using collection methods to modify the collection). For example: public class BuildingType : DomainEntity { /* rest of class */ public IEnumerable<ActionType> ActionsGranted { get { return _actionsGranted; } } private readonly IList<ActionType> _actionsGranted = new List<ActionType>(); private readonly Image _buildingTile; public virtual Image BuildingTile { get { return _buildingTile; } } } But as far as I remember fluent-nhibernate's automapper never had a solution for private readonly backing fields, I'm wondering if that's changed in the last few months. So here's my question: How do I configure automapper or create an automapping convention to map private readonly backing fields?

    Read the article

  • Fluent nHibernate - How to map a non-key column on an association table?

    - by The Matt
    Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly: I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate? An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map: public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasMany(x => x.Employee) .Inverse() .Cascade.All(); HasManyToMany(x => x.Products) .Cascade.All() .Table("StoreProduct"); } }

    Read the article

  • How can I ignore properties of a component using Fluent Nhibernate's AutoPersistenceModel?

    - by Jason
    I am using Fluent NHibernate AutoMappings to map my entities, including a few component objects. One of the component objects includes a property like the following: public string Value { set _value = value; } This causes an NHibernate.PropertyNotFoundException: "Could not find a getter for property 'Value'..." I want to ignore this property. I tried creating an IAutoMappingOverride for the component class but I couldn't use AutoMapping<.IgnoreProperty(x = x.Value) for the same reason. "The property or indexer 'MyComponent.Value' cannot be used in this context because it lacks the get accessor" I've also looked at IComponentConvention but can't see anyway of altering the mappings with this convention. Any help would be appreciated... Thanks

    Read the article

  • Does Anyone Know Of A Solid Web Example Using ASP.NET MVC1 or MVC2, NHibernate, Fluent NHibernate &

    - by Sara
    I am looking for solid non-console examples of how to use ASP.NET MVC1 or MVC2, NHibernate, Fluent NHibernate & Castle. I looked at Sharp Architecture and its just too much to digest for my newbie mind. I need a clean, clear, concise Step A, Step B, Step C tutorial or a solid example that is a web application and not a console application. I have searched and searched and searched and I have found incomplete examples (examples with just enough information to make me say where does that code go), console applications and no good web application examples. Does anyone know of a COMPLETE web example? If I see another console example, I'm going to scream....

    Read the article

  • What is the "Entity" reffering to in fluent Nhibernate Mapping Configuration?

    - by percent20
    I am trying to learn fluent nhibernate better so am doing a basic sample application from scratch, instead of using someone elses framework. However, I am finding I really don't understand what is going on in assigning mapping files. I have seen a lot of code examples which are all showing the same code, but nothing that spells it out. No description of how it works just that it works. Here is a code example that I see often. return Fluently.Configure() .Database(config) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entity>()) .BuildSessionFactory(); So in the code example what is Entity? and how does that piece of code work? Part of me thinks it is the name of the assembly, but seeing as how the namespace I am using is usually the name of the assembly the compiler complains that I am using a namespace as a type. I feel this is important and am rather flustered by the fact I can't figure it out. Thanks

    Read the article

  • Can Fluent NHibernate be configured to use an arbitrary prefix on a property backing field?

    - by dommer
    I'm currently using a convention to (auto)map collection properties to backing fields in Fluent NHibernate. So, I map a property "Orders" to a field "_orders". The convention I'm using to do this is: public class HasManyAccessConvention : IHasManyConvention { public void Apply(IOneToManyCollectionInstance instance) { instance.Access.CamelCaseField(CamelCasePrefix.Underscore); } } Can I write a convention that maps a (collection) property to a field with a non-standard prefix (ignoring whether this is good coding practice for the present)? So, the property "Orders" would be mapped to "xyz_orders", for example. If so, how would I go about this?

    Read the article

  • Fluent nHibernate - How to map a non-key column on a junction table?

    - by The Matt
    Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly: I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate? An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map to a property on the Product class: public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasMany(x => x.Employee) .Inverse() .Cascade.All(); HasManyToMany(x => x.Products) .Cascade.All() .Table("StoreProduct"); } }

    Read the article

  • Why are my Fluent NHibernate SubClass Mappings generating redundant columns?

    - by Brook
    I'm using Fluent NHibernate 1.x build 694, built against NH 3.0 I have the following entities public abstract class Card { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual Product Product { get; set; } public virtual Sprint Sprint { get; set; } } public class Story:Card { public virtual double Points { get; set; } public virtual int Priority { get; set; } public virtual IList<Task> Tasks { get; set; } } And the following mappings public class CardMap:ClassMap<Card> { public CardMap() { Id(c => c.Id) .Index("Card_Id"); Map(c => c.Name) .Length(50) .Not.Nullable(); Map(c => c.Description) .Length(1024) .Not.Nullable(); References(c=>c.Product) .Not.Nullable(); References(c=>c.Sprint) .Nullable(); } } public class StoryMap : SubclassMap<Story> { public StoryMap() { Map(s => s.Points); Map(s => s.Priority); HasMany(s => s.Tasks); } } When I generate my Schema, the tables are created as follows Card --------- Id Name Description Product_id Sprint_id Story ------------ Card_id Points Priority Product_id Sprint_id What I would have expected would have been to see the columns Product_id and Sprint_id ONLY in the Card table, not the Story table. What am I doing wrong or misunderstanding?

    Read the article

  • In Fluent NHibernate, how would I map the following domain models?

    - by Brandon
    I have a user class that looks something like this public class User { public virtual int Id { get; set; } public virtual long ValueA { get; set; } public virtual int? ValueB { get; set; } } ValueA is automatically assigned by the system. It is used in a lookup that would map to UserClass. However, if a value for ValueB exists, then it would do the lookup for UserClass in a different way. Right now the way I handle it is to get the User and then perform a separate lookup each time. return user.ValueB.HasValue ? Find(user.ValueB.Value) : Find(user.ValueA); Is there any way to make Fluent NHibernate do this for me so I can have UserClass as a property on the User class instead of having to do the lookup separately? I was thinking of the ComponentMap but I'm not sure how to make it account for the two possible lookup values.

    Read the article

  • Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclas

    - by BigTommy79
    Hi All, I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate. An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class. if anyone knows of any tutorial or example they've come across before please let me know. Thanks, Tim public abstract class Entity { public int Id { get; set; } } public abstract class Debt : Entity { public decimal Balance { get; set; } public IList<Fine> Fines { get; set; } public Debt() { Fines = new List<Fine>(); } } public class CarLoan : Debt { } public class CreditCard : Debt { } public class LoanApplication : Entity { public IList<Debt> ExistingDebts { get; set; } public LoanApplication() { ExistingDebts = new List<Debt>(); } } public class Fine { public Int64 Cash { get; set; } }

    Read the article

  • How do I create/use a Fluent NHibernate convention to automap UInt32 properties to an SQL Server 200

    - by dommer
    I'm trying to use a convention to map UInt32 properties to a SQL Server 2008 database. I don't seem to be able to create a solution based on existing web sources, due to updates in the way Fluent NHibernate works - i.e. examples are out of date. I'm trying to have NHibernate generate the schema (via ExposeConfiguration). I'm happy to have NHibernate map it to anything sensible (e.g. bigint). Here's my code as it currently stands (which, when I try to expose the schema, fails due to SQL Server not supporting UInt32). Apologies for the code being a little long, but I'm not 100% sure what is relevant to the problem, so I'm erring on the side of caution. Most of it is based on this post. The error reported is: System.ArgumentException : Dialect does not support DbType.UInt32 I think I'll need a relatively comprehensive example, as I don't seem to be able to pull the pieces together into a working solution, at present. FluentConfiguration configuration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(connectionString)) .Mappings(mapping => mapping.AutoMappings.Add( AutoMap.AssemblyOf<Product>() .Conventions.Add<UInt32UserTypeConvention>())); configuration.ExposeConfiguration(x => new SchemaExport(x).Create(false, true)); namespace NHibernateTest { public class UInt32UserTypeConvention : UserTypeConvention<UInt32UserType> { // Empty. } } namespace NHibernateTest { public class UInt32UserType : IUserType { // Public properties. public bool IsMutable { get { return false; } } public Type ReturnedType { get { return typeof(UInt32); } } public SqlType[] SqlTypes { get { return new SqlType[] { SqlTypeFactory.Int32 }; } } // Public methods. public object Assemble(object cached, object owner) { return cached; } public object DeepCopy(object value) { return value; } public object Disassemble(object value) { return value; } public new bool Equals(object x, object y) { return (x != null && x.Equals(y)); } public int GetHashCode(object x) { return x.GetHashCode(); } public object NullSafeGet(IDataReader rs, string[] names, object owner) { int? i = (int?)NHibernateUtil.Int32.NullSafeGet(rs, names[0]); return (UInt32?)i; } public void NullSafeSet(IDbCommand cmd, object value, int index) { UInt32? u = (UInt32?)value; int? i = (Int32?)u; NHibernateUtil.Int32.NullSafeSet(cmd, i, index); } public object Replace(object original, object target, object owner) { return original; } } }

    Read the article

  • How do I create/use a Fluent NHibernate convention to map UInt32 properties to an SQL Server 2008 da

    - by dommer
    I'm trying to use a convention to map UInt32 properties to a SQL Server 2008 database. I don't seem to be able to create a solution based on existing web sources, due to updates in the way Fluent NHibernate works - i.e. examples are out of date. Here's my code as it currently stands (which, when I try to expose the schema, fails due to SQL Server not supporting UInt32). Apologies for the code being a little long, but I'm not 100% sure what is relevant to the problem, so I'm erring on the side of caution. I think I'll need a relatively comprehensive example, as I don't seem to be able to pull the pieces together into a working solution, at present. FluentConfiguration configuration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(connectionString)) .Mappings(mapping => mapping.AutoMappings.Add( AutoMap.AssemblyOf<Product>() .Conventions.Add<UInt32UserTypeConvention>())); configuration.ExposeConfiguration(x => new SchemaExport(x).Create(false, true)); namespace NHibernateTest { public class UInt32UserTypeConvention : UserTypeConvention<UInt32UserType> { // Empty. } } namespace NHibernateTest { public class UInt32UserType : IUserType { // Public properties. public bool IsMutable { get { return false; } } public Type ReturnedType { get { return typeof(UInt32); } } public SqlType[] SqlTypes { get { return new SqlType[] { SqlTypeFactory.Int32 }; } } // Public methods. public object Assemble(object cached, object owner) { return cached; } public object DeepCopy(object value) { return value; } public object Disassemble(object value) { return value; } public new bool Equals(object x, object y) { return (x != null && x.Equals(y)); } public int GetHashCode(object x) { return x.GetHashCode(); } public object NullSafeGet(IDataReader rs, string[] names, object owner) { int? i = (int?)NHibernateUtil.Int32.NullSafeGet(rs, names[0]); return (UInt32?)i; } public void NullSafeSet(IDbCommand cmd, object value, int index) { UInt32? u = (UInt32?)value; int? i = (Int32?)u; NHibernateUtil.Int32.NullSafeSet(cmd, i, index); } public object Replace(object original, object target, object owner) { return original; } } }

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >