Click here to Skip to main content
15,890,609 members
Home / Discussions / C#
   

C#

 
QuestionThreading and events Pin
Giorgi Nistor18-Jan-12 21:57
Giorgi Nistor18-Jan-12 21:57 
AnswerRe: Threading and events Pin
BobJanova19-Jan-12 0:57
BobJanova19-Jan-12 0:57 
GeneralRe: Threading and events Pin
Giorgi Nistor19-Jan-12 22:35
Giorgi Nistor19-Jan-12 22:35 
QuestionMaskedTextBox - Different behavior on different machines, Why? Pin
Michel8318-Jan-12 20:52
Michel8318-Jan-12 20:52 
AnswerRe: MaskedTextBox - Different behavior on different machines, Why? Pin
Eddy Vluggen19-Jan-12 0:27
professionalEddy Vluggen19-Jan-12 0:27 
AnswerRe: MaskedTextBox - Different behavior on different machines, Why? Pin
BobJanova19-Jan-12 0:51
BobJanova19-Jan-12 0:51 
GeneralRe: MaskedTextBox - Different behavior on different machines, Why? Pin
Michel8319-Jan-12 1:24
Michel8319-Jan-12 1:24 
QuestionBest Way To Handle Nulls Pin
Kevin Marois18-Jan-12 11:08
professionalKevin Marois18-Jan-12 11:08 
I have this method:

public List<ProjectModel> GetProjects(ProjectType ProjectType, bool ActiveOnly = true, int ParentId = 0)
{
    using (SparesDataContext context = getDataContext())
    {
        List<ProjectModel> retVal = (from p in context.tblProjects
                                        where p.ProjectTypeId == (int)ProjectType &&
                                            p.ParentId == (ParentId == 0 ? p.ParentId : ParentId) &&
                                            p.IsActive == (ActiveOnly ? true : p.IsActive)
                                        select new ProjectModel
                                        {
                                            ParentId = p.ParentId,
                                            ProjectType = (ProjectType)p.ProjectTypeId,
                                            Caption = p.Caption,
                                            Warehouse1 = getWarehouseModel(p.WarehouseId1 == null ? 0 : p.WarehouseId1.Value),
                                            Warehouse2 = getWarehouseModel(p.WarehouseId1 == null ? 0 : p.WarehouseId1.Value),
                                            IsActive = p.IsActive.Value,
                                            Revision = p.Revision,
                                            Comments = p.Comments
                                        }).ToList();

        return retVal;
    }
}


The Warehouse Id's can be null in the table. In this code if the WarehouseId from the table
is null I convert it to 0 before calling getWarehouseModel. If it's zero I then return an empty WarehouseModel.

This doesn't feel right. Anyone know a better approach?

Thanks
Everything makes sense in someone's mind

AnswerRe: Best Way To Handle Nulls Pin
PIEBALDconsult18-Jan-12 11:26
mvePIEBALDconsult18-Jan-12 11:26 
GeneralRe: Best Way To Handle Nulls Pin
fjdiewornncalwe18-Jan-12 11:31
professionalfjdiewornncalwe18-Jan-12 11:31 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult18-Jan-12 12:21
mvePIEBALDconsult18-Jan-12 12:21 
GeneralRe: Best Way To Handle Nulls Pin
Kevin Marois18-Jan-12 11:53
professionalKevin Marois18-Jan-12 11:53 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult18-Jan-12 12:17
mvePIEBALDconsult18-Jan-12 12:17 
GeneralRe: Best Way To Handle Nulls Pin
BobJanova18-Jan-12 22:28
BobJanova18-Jan-12 22:28 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult19-Jan-12 2:20
mvePIEBALDconsult19-Jan-12 2:20 
GeneralRe: Best Way To Handle Nulls Pin
jschell19-Jan-12 8:34
jschell19-Jan-12 8:34 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult19-Jan-12 13:47
mvePIEBALDconsult19-Jan-12 13:47 
GeneralRe: Best Way To Handle Nulls Pin
BobJanova19-Jan-12 22:14
BobJanova19-Jan-12 22:14 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult20-Jan-12 2:15
mvePIEBALDconsult20-Jan-12 2:15 
GeneralRe: Best Way To Handle Nulls Pin
jschell20-Jan-12 12:08
jschell20-Jan-12 12:08 
GeneralRe: Best Way To Handle Nulls Pin
PIEBALDconsult20-Jan-12 14:57
mvePIEBALDconsult20-Jan-12 14:57 
GeneralRe: Best Way To Handle Nulls Pin
jschell23-Jan-12 7:52
jschell23-Jan-12 7:52 
GeneralRe: Best Way To Handle Nulls Pin
jschell19-Jan-12 8:36
jschell19-Jan-12 8:36 
AnswerRe: Best Way To Handle Nulls Pin
fjdiewornncalwe18-Jan-12 11:29
professionalfjdiewornncalwe18-Jan-12 11:29 
GeneralRe: Best Way To Handle Nulls Pin
BobJanova18-Jan-12 22:29
BobJanova18-Jan-12 22:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.