0

I'm trying to load an object I wrote the the DB using EntityFramework.

public class MyClass
{
    [key]
    public long ID {get; set;}


    private string m_someField {
    public string SomeField {
    get
    {
        return m_someField;
    }
    set
    {
            //DO SOMETHING THAT NEEDS THE VALUE OF SomeField2...
    }
    }

    public string SomeField2 { get; set;}
}

How can I Tell EF to first fill in SomeField2 and only then the fill other fields?

Idov
  • 5,006
  • 17
  • 69
  • 106

1 Answers1

1

I am unsure if EF can load columns in a certain order, and can't think of a use case requiring it.

You could only load the SomeField2 column using projection, and then load the entire object again and merge it into the first one.

However, why not just have a SetSomeField() method that you can either call in the setter of SomeField2, or after the object has been loaded?

danielmcn
  • 390
  • 6
  • 15