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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:44:51+00:00 2026-06-09T11:44:51+00:00

I have a silverlight mvvm with ria project. I have a UI in which

  • 0

I have a silverlight mvvm with ria project. I have a UI in which admin users can enter info to create new work orders. However, I am having trouble calling the db and adding a new record to the table. I have no code-behind for the UI, the controls are tied to the model through Commands and Command Parameters. So when a user clicks, ‘Add new job’ it comes here,

public class EditJobViewModel : ViewModelBase
{
    private Job _job;

    public Job CurrentJob
    {
        get { return _job; }
        set
        {
            _job = value;
            OnPropertyChanged("CurrentJob");
        }
    }

    public ICommand NewJob
    {
        get
        {
            return new DelegateCommand(BeginNewJob, (o) => true);
        }

    }


    public void BeginNewJob(object o)
    {

            _job = new Job();
            //_job.JobNumber = _job.JobID.ToString();
            _job.AssignedTo = App.userID;
            _job.AddedBy = App.userID;
            _job.FileTypeJob = "PDF";
            _job.AddedTS = DateTime.Now;
            _job.OpenDate = DateTime.Now;
            BeginSave(o);
        }
    }

Where Im having trouble is creating a new record in the ‘Job’ table. On my breakpoint it returns all the columns it needs to, just not a new ‘JobID’ which is my primary key. This is how I was supposedly trying to create a new record.

public void BeginSave(object o)
    {
        if (!IsDesignTime)
        {
            try
            {
                if (CurrentJob.EntityState == EntityState.New)
                {
                    CurrentJob.AddedBy = App.userID;
                    CurrentJob.AddedTS = DateTime.Now;
                }
                CurrentJob.UpdatedBy = App.userID;
                CurrentJob.UpdatedTS = DateTime.Now;

                // This is here because of a bug in infragistics grid/Entity Framework 
                foreach (JobFileType ft in CurrentJob.JobFileTypes)
                {
                    if (ft.EntityState != EntityState.Unmodified)
                        (ft as IEditableObject).EndEdit();
                }

                foreach (JobTag tag in CurrentJob.JobTags)
                {
                    if (tag.EntityState != EntityState.Unmodified)
                        (tag as IEditableObject).EndEdit();
                }
                //(CurrentJob as IEditableObject).EndEdit();

                SubmitOperation s = _context.SubmitChanges();
                if (s.HasError)
                { }
            }
            catch (Exception ex)
            { }
        }
    }

Except that it never hits the EntityState.new. That’s just the way I thought to try it. Im thinking there a way to do it from the ‘BeginNewJob’ command but unable to find a way to create a new JobID or record in general. The Database already has 10000 records and has multiple users creating jobs, so I need a way to get the last job created (getMaxID()??) and increment appropriately, creating a new job on the spot.

  • 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-06-09T11:44:52+00:00Added an answer on June 9, 2026 at 11:44 am

    İf you use guid type for id column, you will not need to find next id and this approach will decouple new objects from previous objects.

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

Sidebar

Related Questions

I am new to Silverlight and have been working with Simple MVVM to create
I have experience with Silverlight + MVVM + WCF RIA. My next project will
I have to create now a multi-screen Silverlight 4 RIA application with MVVM. Each
I have a Silverlight project that uses MVVM with Prism. I followed http://www.telerik.com/help/silverlight/patterns-and-practices-eventtocommand-prism.html I
I have a Silverlight 3 project which compiles and runs fine when compiled on
I have a Silverlight 4 application which uses the MVVM pattern. I have: 1.
I have a Silverlight project I'm converting to MVVM. It's my first time using
I am new to MVVM and Silverlight I have managed to get an example
I have a Silverlight project calling a WCF service. The service method GetData has
I have a Silverlight ModelViewViewModel project that I would like to expose a property

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.