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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:37:19+00:00 2026-05-16T20:37:19+00:00

Here is the question : I have following entities: Every time I update or

  • 0

Here is the question : I have following entities:
alt text

Every time I update or insert a transaction I would like to autodetect the category depending on ReferenceMappingExpression or DescriptionMapppingExpression in CategoryMappings Entity.

I mean, I want to match Transaction.Description to CategoryMappings.DescriptionMapping and if it matches get the FkCategoryID from CategoryMapping and save the transactions.

It is possible to loop through every transaction in list and categorymapping list but I don’t think its good idea. How would you do this? Any suggestions? Any experience of that?

  • 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-16T20:37:19+00:00Added an answer on May 16, 2026 at 8:37 pm

    You can use ObjectStateManager, add a partial OnContextCreated method to your entity context. Add new handler to SavingChanges event of context. Get all added and modified transactions there and do whatever you want inside it. Like this:

    public partial class ModelContainer
    {
        partial void OnContextCreated()
        {
            this.SavingChanges += new EventHandler(ModelContainer_SavingChanges);
        }
    
        void ModelContainer_SavingChanges(object sender, EventArgs e)
        {
            foreach (var item in this.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added))
            {
                SetTransactionDescription(item);
            }
            foreach (var item in this.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified))
            {
                SetTransactionDescription(item);
            }
        }
    
        void SetTransactionDescription(System.Data.Objects.ObjectStateEntry entry)
        {
            Transaction transaction = entry.Entity as Transaction;
            if (transaction != null)
            {
                // Your code
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a silly question, but here it goes.Imagine you have the following
Probably a stupid question, but here goes. In my view, I have the following
A little stuck here. I have a simple question I guess. Given the following
here's my question: I have an MVC3 C# application and I need to update
Here is a question that I have had for some time but never actually
Here is my problem: Domain: I have following Entities: [Sensor] that can be positioned
There was a post on here recently which posed the following question: You have
I have the following Radio Buttons: <form id=bg action=#> <span id=questionText>Question Test Here:</span><br/> <input
I have the following generic question Here is a my generic message interface. public
a noob question here. I have the following code: - (IBAction)selectExistingPicture { if ([UIImagePickerController

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.