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 6071669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:04:25+00:00 2026-05-23T10:04:25+00:00

What is the right way to delete collection element from STE. Currently I use

  • 0

What is the right way to delete collection element from STE. Currently I use the following code:

order.Items[i].MarkAsDeleted();
order.Items.RemoveAt(i);

Looks like it works (and ApplyChanges removes entity in spite I have removed it from collection). But it looks a bit ugly. Am I doint it right? Or may be there are other ways?

  • 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-23T10:04:26+00:00Added an answer on May 23, 2026 at 10:04 am

    This text is taken directly from MSDN:

    The MarkAsDeleted method changes the
    state of the entity to Deleted. This
    method also clears the navigation
    properties on the entity that is being
    marked for deletion. The navigation
    property is set to null if it is
    pointing to a reference object. The
    Clear method is called if the
    navigation property represents a
    collection. When MarkAsDeleted is
    called on an object that is part of a
    collection, the object is removed from
    the collection. To mark each object in
    a collection as deleted, mark the
    objects in a copy of the collection.
    To get the copy of the collection,
    call the ToArray() or ToList() method
    on the collection, as in the following
    example:

    List<Course> courses = department.Courses.ToList();
    foreach (var c in courses)
    {
        // Mark each course in the department as Deleted.
        c.MarkAsDeleted();
    } 
    

    So you are not doing it wrong because once you mark item as deleted it should be already removed from the Items collection so removing item at index will most probably remove break relation with another one.

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

Sidebar

Related Questions

Is this the right way to use delete[] operator? int* a=new int[size]; delete[] a;
I'm currently doing the following to use typed datasets in vs2008: Right click on
I only know of one way: Right click and click 'delete me' How else
What's the right way to control timeouts, from the client, when running against a
What's the right way in Drupal to create reports? I was hoping to use
Is this the right way to return an object from a function? Car getCar(string
Is this the right way of deleting the tail from the linked list in
What is the right way to populate the model for the index page in
What is the right way to perform some static finallization? There is no static
What's the right way to go about saving data like Pages, Numbers and other

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.