Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling DB Nulls
Message
 
To
28/12/2009 13:59:18
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01440804
Message ID:
01440903
Views:
24
>>(3) ExtensionMethods class must be public
>>(4) extension methods must be static and public
>>(5) the first parameter of an extension method defines the type it operates on and is preceeded by 'this'
>>(6) write
>>
>>
>>_ProjectName = ds.Tables[0].Rows[0]["ProjectName"].        // - after the dot GetNonNull() should show up in intellisense
>>
>
>
>IIRC, ds.Tables[0].Rows[0]["ProjectName"] would return type as object. Unless you have an extension method defined for object, it woulnd't show. You'd have to cast the ds.Tables[0].Rows[0]["ProjectName"] to the proper type i.e.:
>
>((int)ds.Tables[0].Rows[0]["ProjectName"]). GetNonNull should then show up in intellisense if its defined for int.

Ok, so here's my method now:
public override void LoadData()
{
    DataSet ds = AppDataAccess.GetProjects(this.RecordId);

    if (ds != null && ds.Tables.Count > 0)
    {
        _ProjectKey = (int)ds.Tables[0].Rows[0]["ProjectKey"];
        _ClientKey = (int)ds.Tables[0].Rows[0]["ClientKey"];
        _ProjectTypeKey = (int)ds.Tables[0].Rows[0]["ProjectTypeKey"];
        _RateTypeKey = (int)ds.Tables[0].Rows[0]["RateTypeKey"];
        _ProjectStatusKey = (int)ds.Tables[0].Rows[0]["ProjectStatusKey"];
        _PriorityKey = (int)ds.Tables[0].Rows[0]["PriorityKey"];
        _ManagerKey = (int)ds.Tables[0].Rows[0]["ManagerKey"];

        int? i = null;
        i.GetNonNull();

        _ProjectName = ds.Tables[0].Rows[0]["ProjectName"].ToString();
        _ProjectCode = ds.Tables[0].Rows[0]["ProjectCode"].ToString();
        _RateAmt = (float)ds.Tables[0].Rows[0]["RateAmt"];
        _EstHours = (float)ds.Tables[0].Rows[0]["EstHours"];
        _TotalHours = (float)ds.Tables[0].Rows[0]["TotalHours"];
        _EstStartDate = (DateTime)ds.Tables[0].Rows[0]["EstStartDate"];
        _EstEndDate = (DateTime)ds.Tables[0].Rows[0]["EstEndDate"];
        _ActualStartDate = (DateTime)ds.Tables[0].Rows[0]["ActualStartDate"];
        _ActualEndDate = (DateTime)ds.Tables[0].Rows[0]["ActualEndDate"];
        _PercentDone = (float)ds.Tables[0].Rows[0]["PercentDone"];
        _Comments = ds.Tables[0].Rows[0]["Comments"].ToString();
        _ProjectType = ds.Tables[0].Rows[0]["ProjectType"].ToString();
        _RateType = ds.Tables[0].Rows[0]["RateType"].ToString();
        _Status = ds.Tables[0].Rows[0]["Status"].ToString();
        _Priority = ds.Tables[0].Rows[0]["Priority"].ToString();
        _MgrFirstName = ds.Tables[0].Rows[0]["MgrFirstName"].ToString();
        _MgrLastName = ds.Tables[0].Rows[0]["MgrLastName"].ToString();

    }
}
Notice that GetNonNull() shows in intellisense for the Int I defined. It does NOT show up on the data row items.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform