Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sorting strings Pin
Not Active1-Sep-09 8:53
mentorNot Active1-Sep-09 8:53 
AnswerRe: Sorting strings Pin
DaveyM691-Sep-09 9:06
professionalDaveyM691-Sep-09 9:06 
AnswerRe: Sorting strings Pin
dan!sh 1-Sep-09 9:09
professional dan!sh 1-Sep-09 9:09 
GeneralRe: Sorting strings [modified] Pin
gamer11271-Sep-09 9:11
gamer11271-Sep-09 9:11 
GeneralRe: Sorting strings Pin
dan!sh 1-Sep-09 9:49
professional dan!sh 1-Sep-09 9:49 
GeneralRe: Sorting strings Pin
gamer11271-Sep-09 10:02
gamer11271-Sep-09 10:02 
GeneralRe: Sorting strings Pin
PIEBALDconsult1-Sep-09 11:21
mvePIEBALDconsult1-Sep-09 11:21 
QuestionDesign Question (Class vs Structs) Pin
student_rhr1-Sep-09 8:00
student_rhr1-Sep-09 8:00 
Hi Everyone,

I have a "one to many" sort of situation. I am using a Key to get subset data. I started out using a class like this:
<code>
public class Contract
{
    public int ContractID {get;set;}
    public int CustomerID {get;set;}
    public string CustomerName {get;set;}
    public string Organization {get;set;}
    public int TermsID {get;}
}
//Then data mapper
public class ContractDataMapper
{
    public static List<Contract> GetContractData(int contractID)
    {
        List<Contract> returnValue = new List<Contract>();
        ... /*data retrieval logic*/
        while(reader.Read())
        {
            Contract contract = new Contract();
            contract.CustomerID = Convert.ToInt32(reader["CustomerID"]);
            contract.CustomerName = reader["CustomerName"].ToString();
            ...
            if(!returnValue.Contains(contract))
                returnValue.Add(contract);
        }
        reader.Close();
        command.Dispose();
        return returnValue();
    }
}
</code>

But I soon realized that this is bad because I had to check to see if this ContractID has any TermsID associated with it and the way it currently is I would have to do something like:

if(ContractDataMapper.GetContractData(1234)[0].TermsID > 0)
    // Do something

Ideally I should have one class Contract and have other properties in a subclass. Now my question is ... do you think it would be better to have a struct or a subclass or something else?
// Something like this
Contract contract = new Contract(1234);
List<SubsetData> subset = contract.SubsetData;

I would appreciate your help.
AnswerRe: Design Question (Class vs Structs) Pin
PIEBALDconsult1-Sep-09 8:54
mvePIEBALDconsult1-Sep-09 8:54 
Questionusing webbrowser to Interact with a Flash control??? Pin
Member 65252411-Sep-09 6:54
Member 65252411-Sep-09 6:54 
QuestionDatabase connection question Pin
tonyrdye1-Sep-09 6:35
tonyrdye1-Sep-09 6:35 
AnswerRe: Database connection question Pin
musefan1-Sep-09 6:43
musefan1-Sep-09 6:43 
AnswerRe: Database connection question Pin
Kevin Marois1-Sep-09 18:24
professionalKevin Marois1-Sep-09 18:24 
AnswerRe: Database connection question Pin
seoamitk1-Sep-09 22:42
seoamitk1-Sep-09 22:42 
AnswerRe: Database connection question Pin
seoamitk1-Sep-09 23:06
seoamitk1-Sep-09 23:06 
QuestionGetting DBMS/Database server list using C# Pin
AhmedMasum1-Sep-09 3:59
AhmedMasum1-Sep-09 3:59 
AnswerRe: Getting DBMS/Database server list using C# Pin
Henry Minute1-Sep-09 4:17
Henry Minute1-Sep-09 4:17 
GeneralRe: Getting DBMS/Database server list using C# Pin
AhmedMasum1-Sep-09 4:28
AhmedMasum1-Sep-09 4:28 
GeneralRe: Getting DBMS/Database server list using C# Pin
Henry Minute1-Sep-09 4:38
Henry Minute1-Sep-09 4:38 
GeneralRe: Getting DBMS/Database server list using C# Pin
AhmedMasum2-Sep-09 3:29
AhmedMasum2-Sep-09 3:29 
QuestionMemory leakage in c# multithreading application windows service application Pin
susantasamanta851-Sep-09 3:42
susantasamanta851-Sep-09 3:42 
AnswerRe: Memory leakage in c# multithreading application windows service application Pin
DaveyM691-Sep-09 3:46
professionalDaveyM691-Sep-09 3:46 
AnswerRe: Memory leakage in c# multithreading application windows service application Pin
Dave Kreskowiak1-Sep-09 5:12
mveDave Kreskowiak1-Sep-09 5:12 
Questionwebbrowser stealing focus Pin
yeah10001-Sep-09 3:14
yeah10001-Sep-09 3:14 
AnswerRe: webbrowser stealing focus Pin
OriginalGriff1-Sep-09 3:38
mveOriginalGriff1-Sep-09 3:38 

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.