.net - NHibernate 'Where' Clause Causing Problems On Cascading Deletes?

Jan 21, 2011

I have the following mapping file for 'Photo' objects (edited for brevity):

<hibernate-mapping ... default-access="property" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Photo" table="Photos">
<id name="PhotoId" unsaved-value="0"> [code]...

How can I get around this?

View 1 Replies


Similar Messages:

NHibernate One-To-Many Delete Not Cascading?

Jan 21, 2011

I have a 'Photo' class and a 'Comment' class. An Photo can have multiple comments assigned to it.I have this configured as a one-to-many relationship within my HBM mapping file, and have set cascade="all-delete-orphan" against the 'Comments' bag within the Photo.hbm.xml mapping file.

However, if I try to delete a Photo which has 1 or more Comments associated with it, I am getting 'The DELETE statement conflicted with the REFERENCE constraint "FK_Comments_Photos"'

I tried a couple of other cascade options against the Comments bag in my Photo.hbm.xml but regardless of what I set it to, I'm getting the same outcome each time. I just want to be able to delete a Photo and have any associated comments automatically delete too.

Here is my Photo mapping (edited for brevity):

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" .... default-access="property" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Photo" table="Photos">
<id name="PhotoId" unsaved-value="0">[code]....

Here is my Comment mapping (edited for brevity):

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ... default-access="property" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Comment" table="Comments">
<id name="CommentId" unsaved-value="0">[code]...

why the cascade is not happening when I try to delete a Photo with comments associated with it?

UPDATE: The only way I can get the cascade to happen is to configure the 'Delete Rule' within SQL Server against this relationship to 'Cascade', and in doing so means that I don't need to specify any cascade action within my NHibernate Mapping. However, this isn't ideal for me - I'd like to be able to configure the cascade behaviour within the NHibernate Mapping ideally, so I'm still confused as to why it doesn't appear to be taking any notice of my NHibernate cascade setting?

View 2 Replies

IIS Deletes System.Web.Extensions.dll?

Aug 26, 2010

I moved a site to another server, it worked fine for a a while, but then crashed. I figured out that System.Web.Extensions.dll was missing, so I copied it again. After a while it was missing again. Using Process Monitor I figured out that IIS (w3wp.exe) deletes the file soon after I copy it to the bin folder. (CreateFile with "Read Attributes, Delete" access.)

View 1 Replies

ADO.NET :: Linq To SQL Transactions With Multiple Deletes?

Sep 29, 2010

I am trying to delete three related objects on one submit. Delete fails on one of the child objects, because of foreign key contraint with another table, It deletes one (the parent) but not the two child objects. All in one SubmitChanges(). I even used the TransactionScope, still same thing. So here is the scenario:

I have an object called Page which has a collection of objects called Webinars. There is another object Called Product which is one to one with Webinar.

[Code]....

View 5 Replies

Access :: Database Deletes Records When Connect?

Oct 6, 2010

I have a problem regarding database. I write to the database fine with this code:

[Code]....

When I close the application and view the Database with access.. the records are added ok, but when I start the application the records are deleted. This is what I have in the Form_Load:

[Code]....

View 1 Replies

Web Forms :: Create One Subroutine To Handle All Deletes For Page?

Mar 5, 2011

I am trying to create one subroutine that can handle all deletes for a web app. I have one delete popup panel in my master page, and I call it each time from my content pages. When an instance of delete is called from a content page, I store the name of a delete subroutine specific to the delete instance in a session variable and popup the delete panel in the master page. If a user types YES into a delete textbox in delete popup panel, a confirmDelete Subroutine in codebehind of the Masterpage is called. When the confirmDelete subroutine in the Masterpage is callled, I want to call a subroutine in the content page that has the name stored in the session variable. What is the simplest way to do that?

View 1 Replies

MVC :: NerdDinner Sample - How Does Delete Work - How To Control Deletes

Jun 7, 2010

I am still at the elementary stages of Linq To Sql and Entities usage. I started practicing MVC developement by following the NerdDinner tutorial here at asp.net, and I back myself up with fully developed NerdDinner sample (1.0 -- still on VS2008). I am also at the first half of the NerdDinner tutorial (I think -- maybe I'm further along) - so far I have gotten up to the Delete View. In the fully developed sample I noted that it uses ascx file (which I guess I will find out if the tutorial also will use
ascx files down the road). My sample app, which I am developing from the tutorial, seems to work OK so far. My issue is that I am not clear how the Delete mechanism works. In the DinnerRepository.cs I have this code (from the tutorial):

[code]....

It looks like a dinner object is being passed to these mechanisms and the delete occurs based on a row ID value. But what if I wanted to delete multiple rows - say where ID between 15 and 20 - how to go about this? I was looking for a Delete statement but am not finding it either in what I have developed so far from my tutorial sample or from the fully developed sample. How can I control Deletes in MVC?

View 1 Replies

ADO.NET :: Does Linq Dbml Need Refreshed After Allowing Cascade Deletes On Tables

Oct 20, 2010

When setting up my database, I forgot to set the delete rule to cascade on foreign keys. Now, I can't delete a user from the ASP.net control panel due to the FK constraints. So, I need to go through all my tables and allow cascade delete on all keys.Once I do this, will I need to redo my Linq .dbml? (ie: delete each table on it and drag it back on) or does it not matter?

View 5 Replies

C# - Javascript Confirm Before Running The Eventhandler, Which Deletes Records From The Databse

Apr 14, 2010

I have button, which fires an event, that deletes a record from the database. This is the source of the button:

<asp:Button ID="btnDelete" runat="server" Text="Delete" onclick="btnDelete_Click" />

But how can I make a confirm box appear before the deletion?

View 1 Replies

DataSource Controls :: Logging Inserts, Updates And Deletes On A Table?

May 27, 2010

Does SQL Server 2008 have a built in way to log all inserts, updates and deletes on a table?The updates, inserts, deletes would come from an asp.net 3.5 webpage using SQLDataSources.If so how would I attach the UserID of the website to the database changes logs?

View 4 Replies

Forms Data Controls :: Page Deletes Records In Database When Refreshed?

Mar 10, 2010

I have created a page with a gridview in asp.net that displays the records of a database table and allows users to delete checked records by clicking on a delete button. After I delete a record and I try to refresh the page from the browser (I am using mozilla)I get the follow message:

"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."

and if I click resend another record is deleted automatically. Even though I am reloading the gridview after the deletion the application executes again the onclick event of the delete button is executed and the gridview things that there is a checkedbox selected so the code executes my delete function again.

Is there any way to get rid of these behavior. I have been trying quit a few things but nothing works for me.

View 2 Replies

Forms Data Controls :: GridView Delete Link Deletes Previous Row?

Jul 28, 2010

The delete link on my gridview deletes the previous row instead of selected row....Also, it doesnot delete the already existing rows. When I add new rows and try to delete them then my delete works that too incorrectly.

View 5 Replies

C# - How To Make The Clause Different

Aug 14, 2010

I have the following code:

CustomerService service;
public CustomerService Service
{
get
{
if (this.service == null)
{
this.service = new CustomerService();
}
return this.service;
}
}
public DataTable GetCustomers()
{
return this.Service.GetCustomers();
}

Now the question is: if I wrote the above method as follow (without "this"), it's giving me an error : instance is not reference to an object.

public DataTable GetCustomers()
{
return Service.GetCustomers(); // this will spell the error "instance is not reference to an object"
}

Does anyone know? also it only happens while running via IIS and not from casini web server (VS 2010).

View 4 Replies

ADO.NET :: Is It Possible To Use OFTYPE In Where Clause Of An Entitydatasource

Nov 30, 2010

is it possible to use OFTYPE in where clause of an entitydatasource? I mean something like this:

srcUsers.Where = "OFTYPE(Doctor)";

View 1 Replies

SQL Server :: Group By Clause In CTE?

Mar 30, 2011

I have a query with group-by clause. I want to use it in recusionCTE.How is it possible?I want to know the totalamount for each fname done through this query:select top 10 fname,SUM(totamt) as 'Total Amount' from tables_list group by fname order by 'Total Amount' descBut when any person logins he must be able to see this list for his own hierarchy down the line including himself.

View 2 Replies

ADO.NET :: Using Where Clause Before Select In LINQ?

Aug 26, 2010

why use where condition before select statement in LINQ

View 2 Replies

ADO.NET :: Convert The Where Clause To Linq?

Oct 22, 2010

how do you convert the WHERE clause of this statement to Linq ?

View 1 Replies

Web Forms :: How To Use Dynamically SQL Where Clause

Mar 22, 2010

how to use dynamically SQL Where Clause

[Code]....

View 3 Replies

ADO.NET :: How To UPDATE With Extraneous WHERE Clause

Jul 31, 2010

I'm working on an MVC 2 website, with LINQ. I have the following section to handle updating my Photo object.

[Code]....

In this case, only the field Title changes. But I'm wondering why the WHERE clause isnot simply WHERE PhotoId = @p0... because PhotoId is the primary key. Is there anything I need to do when mapping or something to get the WHERE clause that I expect?

View 4 Replies

Asp - Syntax Error In FROM Clause

Oct 18, 2010

I'm working on asp.net web application & for this use MS access for back end, My Query is given below which is successfully executed on MS Access but error on front end ("Syntax Error in FROM Clause")

select USER.EMPID as EMPID,USER.FULLNAME as FULLNAME,
USER.USERNAME as USERNAME,Employee.ROLEID,ROLE.ROLENAME AS ROLE
FROM USER
inner join employee on user.userid=employee.userid
inner join role on employee.roleid=role.roleid
WHERE USER.EMAIL='admin@itiersolutions.com'
AND USER.PASSWORD='cZdqAEeDV2EVzA1JNFJ6hQ=='
AND USER.STATUS='Enable'

View 4 Replies

C# - EntityDataSource - Where Clause From Different Table?

Nov 22, 2010

I am using EF 4 and EntityDataSource in a Page (WebForms).

This page contains a DropDownList that display UserName.
Data from this DropDownList it is from "aspnet_Users".
At the moment I am using a single EntityDataSource code belove:
<asp:EntityDataSource ID="EntityDataSourceListUsers" runat="server" ConnectionString="name=CmsConnectionStringEntityDataModel"
DefaultContainerName="CmsConnectionStringEntityDataModel" EnableFlattening="False"
EntitySetName="aspnet_Users" Select="it.[UserId], it.[UserName]">
</asp:EntityDataSource>

I need to FILTER the UserName associated to a specific ROLE and displaying it in the DropDownList therefore using others tables"aspnet_UsersInRoles" and "aspnet_Roles".

How to do it?
Would be great have a simple solution since I am a beginner.

View 1 Replies

Using An IN Clause In Vb.net To Save Something To The Database Using SQL?

Sep 30, 2010

I have a textbox and a button on a form.

I wish to run a query (in Vb.Net) that will produce a query with the IN Values.

Below is an example of my code

myConnection = New SqlConnection("Data Source=sqldb;Initial Catalog=Rec;Integrated Security=True")
myConnection.Open()
myCommand = New SqlCommand("UPDATE dbo.Recordings SET Status = 0 where RecID in ('" & txtRecID.Text & "') ", myConnection)
ra = myCommand.ExecuteNonQuery()
myConnection.Close()
MsgBox("Done!", _
MsgBoxStyle.Information, "Done")

When i enter a single value it works but when i enter values with commas it throws an error
"Conversion failed when converting the varchar value '1234,4567' to data type int."

View 2 Replies

VS 2010 - Passing Value To SQL Where Like Clause

Jul 25, 2011

I'm trying to pass the value string.empty to a parameter for a repeater but it does not work, here is code:

Code:
protected void Page_Load(object sender, EventArgs e)
{
EnableViewState = false;
string fromdate = (string)Session["thefromdate"];
string todate = (string)Session["thetodate"];
if ((string)Session["selectedserver"] == "All Servers")

[Code] ....

Thats the gyst of the onload code that deals with my session parameters, as you can see if the session parameter is passed "all servers" it sets the lable value to string.empty (have also tried seting it to "")

Code:
asp:Repeater ID="Repeater1" runat="server" DataSourceID="reoeaterappresuts">
<itemtemplate>
<b><u>Servername:</u>      <%# DataBinder.Eval(Container.DataItem, "Servername") %>      
<u>Date of check:</u>      <%# DataBinder.Eval(Container.DataItem, "Checkdate") %>      
<a href="/appdrilldown.aspx?entryid=<%# DataBinder.Eval(Container.DataItem, "EntryID") %>">

[Code] ....

And the front end repeater stuff, Why can i not pass across "where x like '%%'

It picks up the parameters from the labels on the page set onload....

View 4 Replies

Function And Variable Declaration Without An 'As' Clause?

Aug 25, 2010

I get a message - "Function without an 'As' clause" for HMAC_MD5 and "Variable declaration without an 'As' clause" for Key and Value. But the code works. But the messages still exists. Is there a way to fix this to avoid the messages?

[Code]....

View 4 Replies

ADO.NET :: Unable To Update Records Using IN Clause?

Sep 15, 2010

I've a common function as shown below:

[Code]....

[Code]....

When I want to update records in a table, I usually invoke as shwon below:

[Code]....

This code works fine. But when I'm trying to update multiple records using IN clause, it does not work. Can any one tell me how to do it using IN clause?

I need to update all vendors available in lstVendorId to status 4. I tried below but it does not work.

[Code]....

The above code does not throw any error but it does not update any records either.

View 1 Replies







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