NHibernate Update Using Composite Key?

May 11, 2010

I have a table defnition as given below:

License

ClientId
Type
Total
Used[code]....

If a client used a license to create a user, I need to update the Used column in the table. As I set ClientId column as the id column for this table in the mapping xml, I am getting TooManyRowsAffectedException. how to set a composite key at mapping level so that NHibernate can udpate based on ClientId and Type.

Something like: Update License SET Used=Used-1 WHERE ClientId='xxx' AND Type=1

View 3 Replies


Similar Messages:

C# - Fluent NHibernate Many-to-many Mapping With Auto-generated Pk Instead Of Composite Key?

Feb 2, 2010

I'm working on a RoleProvider in .NET, using Fluent NHibernate to map tables in an Oracle 9.2 database.

The problem is that the many-to-many table connecting users and roles uses a primary key generated from a sequence, as opposed to a composite key. I can't really change this, because I'm writing it to be implemented in a larger existing system.

Here is my UserMap:

public UserMap()
{
this.Table("USR");[code].....

Yet, this is giving me the error:

Type 'FluentNHibernate.Cfg.FluentConfigurationException' in assembly 'FluentNHibernate, Version=1.0.0.593, Culture=neutral, PublicKeyToken=8aa435e3cb308880' is not marked as serializable.

Is there a simple fix to allow this HasMayToMany to use my PersistentObjectMap extension? I'm thinking I may have to add a convention for this many-to-many relationship, but I don't know where to start with that, since I've just started using NHibernate and Fluent NHibernate only recently.

EDIT: I think I've found a possible solution here: http://marekblotny.blogspot.com/2009/02/fluent-nhbernate-and-collections.html

I'll try the above method of creating an entity and a class map for the linking table and post my findings.

EDIT 2: I created a linking entity as mentioned in the above blog post and downloaded the newest binaries (1.0.0.623).
This helped me discover that the issue was with setting lazy load and trying to add roles to the user object in a completely new session.

I modified the code to move OpenSession to the BeginRequest of an HttpModule as described here. After doing this, I changed my data access code from wrapping the open session in a using statement, which closes the session when it is finished, to getting the current session and wrapping only the transaction in a using statement.

This seems to have resolved the bulk of my issue, but I am now getting an error that says "Could not insert collection" into the USR_ROLE table. And I'm wondering if the above code should work with a UserRoleMap described as:

public UserRoleMap()
{
this.Table("USR_ROLE"); [code]....

Hibernate's documentation for many-to-many relationship suggests creating an object to maintain a one-to-many/many-to-one, as in an ERD. I'm sure this would be much easier with conventional naming standards, but I have to stick with certain abbreviations and odd (and not always properly-implemented) conventions.

View 1 Replies

Web Forms :: Dynamic Composite Controls Within Update Panel?

Aug 1, 2010

Dynamic Composite Controls Within Update Panel?

View 2 Replies

ADO.NET :: Does Entity Framework 3.5 Support Composite Foreign Key/Composite Primary Key

Dec 14, 2010

Does ADO.Net Entity Framework 3.5 support Composite Foreign key/Composite primary key?

View 5 Replies

C# - Update Parent Table From Child In Fluent Nhibernate?

Jul 13, 2010

I'm trying to update the data in the parent table that is referenced in the child table from the child's view in Asp.net.

I mapped the tables using Fluent Nhibernate.

In the child table, the mapping looks like this:

[code]....

View 1 Replies

SQL Server :: Looking For Composite Primary Key?

Dec 20, 2010

Why do we need to have Composite Primary Key

Can't we set one column as Primary and others as Unique key.

View 4 Replies

C# - How To Delete Record From DB Having Composite Key

Dec 11, 2010

I have asp.net app where I am using gridview for data showing, editing and deleting. Now I want to delete or edit record from table and I need to pass 3 cols in DataBinder.Eval(Container.DataItem,"colName"). how i can do this?

EDITED

Basically when i need to update or delete record from asp.net app, I have to pass values of 3 columns (which are composite keys) to my UDF. Now How I can pass 3 different values to DataBinder.Eval() and reading them in GridView Rowcommand event.

View 2 Replies

Registering A Composite Control?

Dec 13, 2010

I am learning custom controls and just finished my first one. The problem is that I am struggling to register it in my web config and have the compiler recognize it. Right now this results in a YSOD about the reference to the control.

note: exact error - Error Unknown server tag 'cc:LblTextBox'.

Web Config

//..
//..
<pages>
<controls>
<add tagPrefix="cc" namespace="Controls.Server"/>
</controls>
</pages>
</system.web>
The control code-behind
namespace Controls.Server
{
public class LblTextBox : CompositeControl
{
//...
}
}
mark-up
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlsMain.aspx.cs" Inherits="Pages_ControlsMain" Trace="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Controls Area</title>
</head>
<body>
<form id="form1" runat="server">
<div>
First attempt at a simple composite control <br />
<cc:LblTextBox ID="ccLblTbHybrid" runat="server" LabelText="Name:" />
</div>
</form>
</body>

View 2 Replies

How To Make Composite Key And Foreign Keys

Mar 22, 2011

I am developing asp.net MVC3 application and I have following entity

This entity has composite key (CreditRegistryId and Accoubnt No are primary keys). CreditRegistryId is a foreign key as well. How can I make composite key and foreign key. I am using DbContext API from EF 4.1. I am not using edmx ( ORM designer)

[code]...

View 1 Replies

C# - Converting Listview To A Composite Control?

Mar 8, 2010

The link below shows a listview composite control in its most basic form however I can't seem to extend this to what I'm trying to do.

http://stackoverflow.com/questions/92689/how-to-define-listview-templates-in-code

My listview has 1 tablerow with 2 fields. The first field contains 1 element whilst the second field contains 2 elements as shown below.

<asp:ListView ID="lstArticle" runat="server">
<LayoutTemplate>
<table id="itemPlaceholder" runat="server"> [code].....

View 1 Replies

MVC :: Composite Primary Key + Editing Of A Table?

Feb 1, 2011

I have a table with composite primary key and this key includes two values referring to two other tables. Now I need to implement Edit feature for this Original Table but I wanted to have dropdown lists while editing pointing to look up tables(composite key values are primary keys for two lookup tables). for eg.

Table1(table1_primarykey, table1_field1)

Table2(table2_primarykey, table2_field1)

Table3( table1_primarykey,table2_primarykey, table3_field1) - composite primary key

while editing I wanted to display table1_field1, table2_field1 instead of original primary keys as numbers in Dropdowns.

View 4 Replies

Adding Jquery Into A Composite Control?

Jun 28, 2010

I am creating a composite control that has a textbox and uses a jquery plugin to add a watermark. Lets say I have a basic function that looks like this

$(function () {$('#MyTextBoxID').watermark('Enter your username');});

Can anyone suggest what I need to do to insert the above?

View 1 Replies

Php - Create Image From Divs Composite?

Apr 7, 2010

I'd like to have a div as a canvas, where users would choose images to show, out of a list. They will choose what background it would have, icons, and they will upload an image which will appear in this canvas too.I'm looking for solutions in PHP or ASP.NET.

View 1 Replies

Registering Composite Classes In Unity?

Nov 25, 2010

in my implementation, I have an interface as: ICachingManager. I've got now one implementation. I also created a manager class as:

public class CachingManager
{
#region Members
private ICachingManager service;

[Code]....

In case I had one implementation, then I can easily register the CachingManager class with Unity, automatically Unity resolves and injects the ICachingManager.

In case I had more than one implementation using named types, then how can I can make use of Unity? Do I need to make use of an Abstract Factory to decide on which named type to initialize?

Is it a good idea to make use of such a composite class or use directly implementations of the interface with Abstract Factory?

View 1 Replies

How To Enhance A Composite Control's Client Side

Aug 30, 2010

I want to enhance a composite control's client side, my approach is to recreate all method on JavaScript, so here I have some troubles :

1) Can I call onclick event on client side otherwise on server side ?

2) the statement table.onclick=SelectRow(event) fires a bug !

View 6 Replies

Scriptmanager - Register Several Composite Scripts Per Page?

May 17, 2010

I want to place several composite scripts to Page. But ScriptManager contains non-Enumerable property CompositeScript.

Is it possible to register several CompositeScript`s per Page?

View 1 Replies

AJAX :: Access ScriptManager In Composite Control?

Oct 4, 2010

Can anybody tell me how can i access ScriptManager in my Composite Control?

I do have reference of system.web in my project but when i type System.Web.UI.

i am not able to get reference of ScriptManager afeter UI.

The reason for doing this is that i have a composite control which is registering some client script on OnPreRender event.

this control works fine when placed on web page without update panel but gives error "object expected" when placed in an update panel

i am registering client script as follows

[Code]....

View 5 Replies

C# - ADO.NET Entity Framework - Composite Primary Key CRUD

Sep 14, 2010

i have following entities as you see BudgetPost has a composite primary key which is a foreign keys to entities Category and Budget. My question is what is the best way to make CRUD? Is there any way to mapp the foreign keys? The simple insert should look like this:

Budget newBudget = new Budget();
newBudget.BudgetName = textBox1.Text;
newBudget.FromDate = dateTimePicker1.Value;
newBudget.ToDate = dateTimePicker2.Value;
newBudget.BudgetPosts.Add(new BudgetPost { FKBudgetID = newBudget.BudgetID, FKCategoryID = 21, BudgetAmount = 700 });
db.AddToBudgets(newBudget);
db.SaveChanges();

View 1 Replies

How To Save Value Across Postbacks For A Composite Control Without Using Viewstate

Oct 29, 2010

I have a composite control that has a couple of private fields that reference values in the cache and these private fields are called during the constructor method. Since a string key is used to identify the value in the cache, I must have a way of storing that string key in such a way that it is available at the time the control is instantiated, and I have to be able to reference it on postbacks without it changing.

In addition, this key is generated the first time the control is loaded, but it should not be changed again after that first time.

How can I accomplish this?

I have already tried saving it to viewstate, but that doesn't work because viewstate is not yet available at the time the control is instantiated.

I have tried using a private field and then checking against Page.IsPostback in the constructor and if it isn't postback, I assign a value to the private field, but on subsequent postbacks it looses it's value, and I can't reassign it in the Page.IsPostBack again because it is an autogenerated GUID.

View 3 Replies

ADO.NET :: Newbie - How To Define A Composite Primary Key In A Model

Feb 28, 2011

I have a table where a primary key is a composite key build from columns: phone_nr and phone_ext.

How do you put a KeyAttribute in a Model in this case?

When a primary key is one column in a Model I coded:

[Key]
public string category_name { get; set; }
public string user_id { get; set; }

in the above case the column category_name is the primary key, but what to do when you have a composite primary key?

View 2 Replies

Build A Composite Or Template Control In MVC Or The Equivalent?

May 10, 2010

In our current ASP.Net Webforms application we have several composite/template server controls that only exist for a common look and feel. For example, we have a panel control that has a title, a place for buttons related to the contents of the panel, and of course the contents. How is this best accomplished in MVC? RenderPartial doesn't get done what I need here. Should I still be using the same controls, but just on a view page? These controls don't really do anything on postback, they are only there for a common look and feel.

More Info:

We have a control in Webforms that implements ICompositeControl. We have a few properties on this control like Panel (type Panel), Buttons (again type Panel which would hold buttons) and a property Title of type string. Visually it looks like

View 2 Replies

C# - Simple Composite Control - Postback Not Working?

Nov 17, 2010

I am trying to make a simple composite control - just a label and textbox - but the postback isn't being picked up by the control.I haven't implemented IPostBackDataHandler as according to this its not necessary - the TextBox control should tie in automagically. A composite control that includes a TextBox need not worry about postbacks, as the embedded control will work it out with ASP.NET automatically.

class TestControl : WebControl
{
Label _label;

[code]...

View 1 Replies

C# - Creating Composite Control With Client Feature?

Nov 7, 2010

I want to develop composite control where some of the work would be executed on client side. For that I am implementing IScriptControl.

ScriptReference points to a script file with client object.

Let's say I want it to have Listview(html select) control that onselect will run javascript function based on the selected value.

I can't just create the control dynamically is client js, because the control has UI on design mode so I must create the select control on server side (I create it in override void Render)

My problem how and where to assign the onselect event for the selection.

Update: Maybe I should add select's id as property to ScriptControlDescriptor, then in client control retrieve this id and attach the needed handler to the event?

View 3 Replies

Web Forms :: Composite Control Attribute Assignment?

Mar 29, 2010

I have got a composite control and i would like to dictate which attribute/property is assigned to the control first from the markup?example in the aspx file:

<MM:MyControl ID="" runat="server" ViewType="normal" BaseType="RealBase"></MM:MyControl>

when the control gets created from the mark-up above, ViewType will be assigned first, Which is what I do not want, I would like RealBase to be assigned first under all circumstances. This control is to be users by other developers so I cannot just switch the order.

View 1 Replies

How To Get A Composite-control's Child Controls At Design-time

Jun 23, 2010

I am designing an ASP.NET v3.5 custom control based on CompositeControl.

However, I do NOT want to create my child controls via code, but rather as

embedded HTML tag elements within the CompositeControl in the ASPX page, such as:

[code]....

At run time, MyControl.Controls contains the two labels as expected.

At design time, MyControl.Controls is empty.

I need this information at design time for various reasons.

What am I doing wrong?

View 1 Replies







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