rgfirefly24's Profile User Rating: -----

Reputation: 262 Architect
Group:
Author w/DIC++
Active Posts:
1,460 (0.63 per day)
Joined:
07-April 08
Profile Views:
24,915
Last Active:
User is offline Today, 02:20 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
XBox
Your Car:
Chevrolet
Dream Kudos:
150

Latest Visitors

Icon   rgfirefly24 has not set their status

Posts I've Made

  1. In Topic: What Are You Working On Today?

    Posted 21 Jul 2014

    I just realized that it's already 2 hours till time to go home and I have yet to finish a thing on my to do list. I have unfortunately scheduled my next two days with with clients who want me to do some ticket work for them.
  2. In Topic: Entity framework not Saving to correct table (m-m Relationship)

    Posted 16 Jul 2014

    So I set the EntityState to Unchanged and it worked. Thanks for your assistance.

    Actual code solution:

    I changed the INSERTObject method and added in an iteration over the tags to set their state to Unchanged:

     public void InsertObject(Object s)
            {
                using (var db = new Context())
    
                    if (s != null)
                    {
                        db.Objects.Add(s);
                        foreach(Tag tag in db.Tags)
                        {
                            db.Entry<Tag>(tag).State = EntityState.Unchanged;
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        throw new Exception { };
                    }
            }
    
    
  3. In Topic: Entity framework not Saving to correct table (m-m Relationship)

    Posted 16 Jul 2014

    See here is the thing. The tags are Pre-Definied and gathered from the database and put into a list object. I am not creating New tags, just associating them with an object.

    hence this line to get a list of matching ones:
    var result = tagList.FirstOrDefault<Tag>(s => line.Contains(s.TagDesc));

    Now as far as the Modified entitystate. I will look into that and see if that will work.
  4. In Topic: Entity framework not Saving to correct table (m-m Relationship)

    Posted 16 Jul 2014

    Are the tags new entries or are they updates?

    pre-defined tags (Gathered from the Tags table)

    If they are new entries, you will need to create a new tag and fill out the details, otherwise retrieve the entity from the database.

    This is already done.

    In addition to that if it is a new entry and you are trying to set the identity column to a value, you will need to allow setting of the identity column on insert in order for it to not fail.

    Again, I knew why I was getting the Identity error. That is not the issue in question here.


    All I need to figure out is making it so that an entry gets put into the ObjectTags table with out a new entry getting put into the Tags table. All of the tags are pre-defined in the Tags table.
  5. In Topic: Entity framework not Saving to correct table (m-m Relationship)

    Posted 16 Jul 2014

    I knew why I was getting the Identity error. that wasn't the issue.

    Here is exactly what I am trying to do.

    1. Iterate over a directory structure until you hit the bottom directory. Make this your "Object" (Folder Name).
    2. Gather a list of all SQL files within that directory.
    3. Iterate over said files and get a list of pre-defined tags (Gathered from the Tags table) that exist in these files and make them Tags to the Object in step 1.
    4. Insert a new record into the Object table creating a link (ObjectTags Table) between the Tag and newly entered Object for use in later operations.

    Everything works until step 4.

My Information

Member Title:
D.I.C Lover
Age:
31 years old
Birthday:
February 21, 1983
Gender:
Years Programming:
4
Programming Languages:
C#, VB.NET, Javascript, VBScript

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://

Comments

Page 1 of 1
  1. Photo

    AnalyticLunatic Icon

    06 Feb 2014 - 10:46
    Hey, congrats on the review/raise! Been offline a few days and just now reading through the threads. I've got a 90 day evaluation later this afternoon myself.
Page 1 of 1