• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 62
  • Last Modified:

What is "raw" when it follows a watched value in the Watch window while debugging?

Codebase:  C#
IDE:  Windows Visual Studio Community 2017
Application Kind:  Windows Form

In the below screenshot of my watch window .. what is "raw"?  It correctly shows the value I am wanting.  But I cannot seem to "get to" that value in my custom type at runtime.

Notice that the watch value is what that I created FROM another drill down on "IMC" in the satme watch window (instead of creating it from the code itself).

raw

So my question is:  What is "raw".  And how do I extract that value out at runtime?  I am trying to fill a List<object> with values from a List<InMemoryCell>.  "InMemoryCell" is a custom class I created to hold and manipulate simple value types.

InMemoryType class:
 public class InMemoryCell
    {
        public InMemoryCell()
        {

        }

        public bool isspreadsheetheaderrow = false;
        public string spreadsheetheader { get; set; }
        public int spreadsheetcolumnordinal { get; set; } = -1;
        public string databasetablename { get; set; }
        public string databasetablecolname { get; set; }
        public EnumerationTableNameValue databasenamevaluepair = new EnumerationTableNameValue();
        public EnumerationTableNameValue spreadsheetnamevaluepair = new EnumerationTableNameValue();
        public enumeratedlistoftypes memcelltype = new enumeratedlistoftypes();

        public bool MatchFoundInDatabase()
        {
            bool matchfound = false;

            matchfound = Convert.ToBoolean(GlobalDatabaseHelperMethods.GetDatabaseCellInfo(
                databasetablename,
                databasetablecolname,
                "where " + databasetablecolname + " = '" + spreadsheetnamevaluepair.FriendlyValue.AsTrimmedString + "'",
                memcelltype,
                true).ToString());


            return matchfound;
        }

        public bool CellValueIsValidDouble()
        {
            bool isvalid = false;

            if(CellValueIsNotNull())
            {
                if(!Double.TryParse(this.spreadsheetnamevaluepair.FriendlyValue.AsTrimmedString, out double result))
                {
                    isvalid = true;
                }

            }

            return isvalid;
        }

        public bool CellValueIsValidString()
        {
            bool isvalid = false;

            if(CellValueIsNotNull())
            {
                isvalid = true;
            }

            return isvalid;
        }


        public bool CellValueIsNotNull()
        {
            bool isvalid = false;

            if(this.databasenamevaluepair.FriendlyValue.RawObject != null)
            {
                isvalid = true;
            }

            return isvalid;
        }
    }

Open in new window




runtime snippet where the assignment is attempted:
  public DataTable ConvertListToDataTable(string filterby)
        {
            DataTable dt = new DataTable();

            System.Data.Common.DbDataRecord dbdr;

            foreach(object o in _dmap)
            {
                dbdr = (System.Data.Common.DbDataRecord)o;

                dt.Columns.Add(dbdr["Heading"].ToString());

            }

            List<InMemoryCell> memcellrow = new List<InMemoryCell>();
            List<object> objectrow = new List<object>();
            object temp;
            object temp2;

            EnumerationTableNameValue entv;

            foreach(var aa in rowsfound)
            {
                memcellrow = aa.ToList<InMemoryCell>();
                
                foreach(InMemoryCell imc in memcellrow)
                {
                    if(imc.databasetablename == filterby)
                    {
                        entv = new EnumerationTableNameValue();

                        entv = imc.databasenamevaluepair;









///////////////////////////////////////// NO MATTER WHAT I TRY /////////////////////////////////////////////////
//////////////////////////////////////  temp (or temp2) is always NULL   //////////////////////////////////////

                        temp = null;
                        temp = imc.databasenamevaluepair.FriendlyValue.RawObject;
                        temp2 = "";
                        temp2 = entv.FriendlyValue.AsTrimmedString;
                        objectrow.Add(temp);








                    }
                }

                dt.Rows.Add(objectrow.ToArray<object>());
            }

            return dt;  //dt is a "DataTable" as in System.Data.DataTable...

        }

Open in new window

0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
Hi Tom;

The error message states "object does not contain a definition for 'raw',". The object they are talking about is "imc.databasenamevaluepair.FirendlyValue.RawObject", is it a class hierarchy that you created and if so can you post the class/s here because raw has not been defined.
0
 
Tom KnowltonWeb developerAuthor Commented:
Fernando:

Thank you for your reply.  

I ended up going in a different direction, so the question is kind of moot now.  But, I will post my solution and my other code that was problematic.


Eventual Solution:
   public DataTable ConvertListToDataTable(string filterby)
        {
            DataTable dt = new DataTable();
            List<List<InMemoryCell>> memcellrow = new List<List<InMemoryCell>>();
            List<object> lo;
            InMemoryCell lll;

            for(int i = 0; i < this.rowsfound.Count; i++)
            {
                lo = new List<object>();
                int innercount = this.rowsfound[i].Count();

                for(int k = 0; k < innercount; k++)
                {
                    string tempheader = this.rowsfound[i][k].spreadsheetheader;

                    if(!dt.Columns.Contains(tempheader))
                    {
                        dt.Columns.Add(tempheader);
                    }

                    lo.Add(this.rowsfound[i][k].spreadsheetnamevaluepair.FriendlyValue.RawObject);
                }

                object[] oa = lo.ToArray();
                dt.Rows.Add(oa);
                lo.Clear();
            }

            return dt;

        }//end of method

Open in new window



Universal Data Class code:
 public class UniversalDataClass
    {
        public UniversalDataClass() { }
        public UniversalDataClass(object o)
        {
            this.RawObject = o;
        }

        public object RawObject { get; set; } = null;

        public string AsTrimmedString
        {
            get
            {
                if(this.RawObject != null)
                {

                    return this.RawObject.ToString().Trim();
                }
                else
                {
                    return "";
                }
            }
        }
        public int AsInt32
        {
            get
            {
                int temp = -1;

                if(IsAValidInt32())
                {
                    temp = Convert.ToInt32(this.RawObject.ToString().Trim());
                }

                return temp;
            }
        }
        public double AsDouble
        {
            get
            {
                double temp = -1.00D;

                if(IsAValidDouble())
                {
                    temp = Convert.ToDouble(this.RawObject.ToString().Trim());
                }

                return temp;
            }
        }
        public bool AsBool
        {
            get
            {
                bool temp = false;

                if(IsAValidBool())
                {
                    temp = Convert.ToBoolean(this.RawObject.ToString().Trim());
                }

                return temp;
            }
        }
        public DateTime AsDateTime
        {
            get
            {
                DateTime temp = new DateTime();
                temp = DateTime.Now;

                if(IsAValidDateTime())
                {
                    temp = Convert.ToDateTime(this.RawObject.ToString().Trim());
                }

                return temp;
            }
            set { }
        }
        private bool IsAValidInt32()
        {
            bool isvalidint = false;

            if(this.RawObject != null)
            {
                isvalidint = Int32.TryParse(this.RawObject.ToString().Trim(), out int result);
            }

            return isvalidint;
        }
        private bool IsAValidDouble()
        {
            bool isvaliddouble = false;
            if(this.RawObject != null)
            {
                isvaliddouble = Double.TryParse(this.RawObject.ToString().Trim(), out double result);
            }

            return isvaliddouble;
        }
        private bool IsAValidBool()
        {
            bool isvalidbool = false;

            if(this.RawObject != null)
            {
                isvalidbool = Boolean.TryParse(this.RawObject.ToString().Trim(), out bool result);
            }

            return isvalidbool;
        }
        private bool IsAValidDateTime()
        {
            bool isvaliddatetime = false;


            if(this.RawObject != null)
            {
                isvaliddatetime = DateTime.TryParse(this.RawObject.ToString().Trim(), out DateTime result);
            }

            return isvaliddatetime;
        }

    }

Open in new window



EnumerationTableNameValue Class code:
  public class EnumerationTableNameValue : IDisposable
    {
        public EnumerationTableNameValue() { }

        public UniversalDataClass IDValue = new UniversalDataClass();
        public UniversalDataClass FriendlyValue = new UniversalDataClass();
        public DataTable dt;
        public void CreateNameValueDataTable(string tsql)
        {
            this.dt = GlobalDatabaseHelperMethods.GetTableForDataBoundControlGivenTSQL(tsql);

            if(this.dt.Rows.Count == 1)
            {
                this.IDValue.RawObject = this.dt.Rows[0].Table.Columns[0];
                this.FriendlyValue.RawObject = this.dt.Rows[0].Table.Columns[1];
            }
        }
        public DataTable GetDataTable()
        {
            return this.dt;
        }
        public void Dispose()
        {
            ((IDisposable)this.dt).Dispose();
        }
    }

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
Thank you, Fernando!
0
 
Fernando SotoRetiredCommented:
Always here to help, have a great day.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now