Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:52:10+00:00 2026-05-28T03:52:10+00:00

I’m developing simple Silverlight 4 application based on one-to-many association. The model of relation

  • 0

I’m developing simple Silverlight 4 application based on one-to-many association.
The model of relation is presented here.

The page consists of two grids, one is loaded straightly from DomainDataSource (ExcelTemplate one). After selecting ExcelTemplate the second one is loaded with ColumnValidationRules from ObservableCollection which is filled on base of ExcelTemplate‘s list. Entities does not have OnDelete actions. I have a lot of problems with deleting ColumnValidationRule objects family. Basically I’ve tried 2 different approaches:

  • Deleting only ColumnValidationRule using
    ColumnValidationRuleDomainDataSource (based on GetColumnValidationRule query):

XAML with my DomainDataSources:

                                <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ExcelTemplate, CreateList=true}" Height="0" LoadedData="ExcelTemplateDomainDataSource_LoadedData" Name="excelTemplatesForValidatiorsDDS" QueryName="GetExcelTemplatesQuery" Width="0">
                                    <riaControls:DomainDataSource.DomainContext>
                                        <my1:SRFDomainContext />
                                    </riaControls:DomainDataSource.DomainContext>
                                </riaControls:DomainDataSource>

                                <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ColumnValidationRule, CreateList=true}" Height="0" LoadedData="ExcelTemplateDomainDataSource_LoadedData" Name="columnValidationRulesDomainDataSource" QueryName="GetColumnValidationRulesQuery" Width="0">
                                    <riaControls:DomainDataSource.DomainContext>
                                        <my1:SRFDomainContext />
                                    </riaControls:DomainDataSource.DomainContext>
                                </riaControls:DomainDataSource>

Code:

     // Filling DataViews:
     this.excelTemplatesForValidatiorsDDS.Load();
     this.columnValidationRulesDomainDataSource.Load();

    // Delete action:
    private void DeleteRuleButton_Click(object sender, RoutedEventArgs e)
    {
        this.columnValidationRulesDomainDataSource.Load();
        ColumnValidationRule cvr = this.srfValidatorsDataGrid.SelectedItem as ColumnValidationRule;
        this.columnValidationRulesDomainDataSource.DataView.Remove(cvr);
    }

In result im getting an error:
The specified entity is not contained in this EntitySet.

Error details:

w System.ServiceModel.DomainServices.Client.EntitySet.Remove(Entity entity)
   w System.Windows.Controls.PagedEntityCollectionView.RemoveCore(Entity item, Int32 index)
   w System.Windows.Controls.PagedEntityCollectionView.RemoveItem(Entity item)
   w System.Windows.Controls.EntityCollectionView.Remove(Object item)
   w System.Windows.Controls.DomainDataSourceView.Remove(Object item)
   w LANOS.UserManagement.DeleteRuleButton_Click(Object sender, RoutedEventArgs e)
   w System.Windows.Controls.Primitives.ButtonBase.OnClick()
   w System.Windows.Controls.Button.OnClick()
   w System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   w System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   w MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventN

  • Creating different DomainDataSource for each of objects family:
    ColumnValidationRule, AssociatedColumn, ColumnValue. Then deleting them using those DomainDataSource’s and submitting from the
    tail to head. This approach also failed. I had similar error to
    those in 1st approach. Also from time to time some of those
    DomainDataSource’s were empty.

I was googling after examples which would cover this problem but I have not found any. Appreciating any tips, links or help 😉


UPDATE1:

I have used your advice:

    this.columnValidationRulesDomainDataSource.Load();
    ColumnValidationRule deletedObject = null;

    foreach (ColumnValidationRule cvr in this.columnValidationRulesDomainDataSource.DataView)
    {
        if (cvr.ID.Equals((this.srfValidatorsDataGrid.SelectedItem as ColumnValidationRule).ID))
        {
            deletedObject = cvr;
        }
    }
    this.columnValidationRulesDomainDataSource.DataView.Remove(deletedObject);
    this.columnValidationRulesDomainDataSource.SubmitChanges();

Now im getting this error: The item provided is not instance of type Entity :/


UPDATE 2:

I’ve added on SubmitedChanges Event handler and as I suspected in the beginning of the post, there is a problem with deleting caused by Foreign Keys:

e.Error.Message "Submit operation failed. An error occurred while updating the entries. See the inner exception for details. InnerException message: The DELETE statement conflicted with the REFERENCE constraint \"FK_AssociatedColumn_ColumnValidationRule\". The conflict occurred in database \"LANOS\", table \"dbo.AssociatedColumns\", column 'ColumnValidationRuleID'.\r\nThe statement has been terminated."

Unfortunately I’m not able to set up model to make use of End On Delete – Cascade property.
Setting Cascade deleting cause compilation error:

End 'ColumnValue' on relationship 'LANOSModel.FK_AssociatedColumnColumnValue' cannot have operation specified since its multiplicity is '*'. Operations cannot be specified on ends with multiplicity '*'.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:52:11+00:00Added an answer on May 28, 2026 at 3:52 am

    The reason “the specified entity is not contained in this EntitySet” is because…. wait for it… the specified instance of that entity really is not contained in the EntitySet.

    You have apparently loaded the data grid from a previous data context, whereas this.columnValidationRulesDomainDataSource.Load() is creating a new set of entities, so you cannot remove your specific old object from a new data set. They have the same values but are not the same objects.

    You can however use a key from the object and do a delete on the new context (where the id’s match). Just find the matching instance first and delete that.

    If you can provide more details/code I might be able to provide a specific example, but you should have enough to go on now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.