Click here to Skip to main content
15,895,656 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to translate Win32 error codes Pin
Jörgen Sigvardsson30-Sep-09 2:13
Jörgen Sigvardsson30-Sep-09 2:13 
GeneralRe: How to translate Win32 error codes Pin
Luc Pattyn30-Sep-09 2:20
sitebuilderLuc Pattyn30-Sep-09 2:20 
QuestionProblem In Window Services in C# Pin
Anudeep Jaiswal - MCA30-Sep-09 1:34
Anudeep Jaiswal - MCA30-Sep-09 1:34 
AnswerRe: Problem In Window Services in C# Pin
SeMartens30-Sep-09 1:44
SeMartens30-Sep-09 1:44 
QuestionHow to load entity properties conditionally Pin
Vikas Misra(TCS)30-Sep-09 1:24
Vikas Misra(TCS)30-Sep-09 1:24 
QuestionHow Can I Create Printer Pin
Anubhava Dimri30-Sep-09 1:00
Anubhava Dimri30-Sep-09 1:00 
AnswerRe: How Can I Create Printer Pin
Wes Aday30-Sep-09 1:13
professionalWes Aday30-Sep-09 1:13 
AnswerRe: How Can I Create Printer Pin
Richard MacCutchan30-Sep-09 1:14
mveRichard MacCutchan30-Sep-09 1:14 
Questionfile can be write on XP but can not on VISTA Pin
khosnur30-Sep-09 0:46
khosnur30-Sep-09 0:46 
AnswerRe: file can be write on XP but can not on VISTA Pin
Calla30-Sep-09 1:01
Calla30-Sep-09 1:01 
GeneralRe: file can be write on XP but can not on VISTA Pin
khosnur30-Sep-09 1:07
khosnur30-Sep-09 1:07 
GeneralRe: file can be write on XP but can not on VISTA Pin
Calla30-Sep-09 1:21
Calla30-Sep-09 1:21 
GeneralRe: file can be write on XP but can not on VISTA Pin
khosnur30-Sep-09 1:43
khosnur30-Sep-09 1:43 
GeneralRe: file can be write on XP but can not on VISTA Pin
DaveyM6930-Sep-09 1:28
professionalDaveyM6930-Sep-09 1:28 
GeneralRe: file can be write on XP but can not on VISTA Pin
khosnur30-Sep-09 1:45
khosnur30-Sep-09 1:45 
AnswerRe: file can be write on XP but can not on VISTA Pin
Keith Barrow30-Sep-09 1:09
professionalKeith Barrow30-Sep-09 1:09 
GeneralRe: file can be write on XP but can not on VISTA Pin
khosnur30-Sep-09 1:13
khosnur30-Sep-09 1:13 
AnswerRe: file can be write on XP but can not on VISTA Pin
Richard MacCutchan30-Sep-09 3:05
mveRichard MacCutchan30-Sep-09 3:05 
QuestionCD Burning in VISTA Pin
Edward Topalian30-Sep-09 0:39
Edward Topalian30-Sep-09 0:39 
AnswerRe: CD Burning in VISTA Pin
Christian Graus30-Sep-09 0:43
protectorChristian Graus30-Sep-09 0:43 
AnswerRe: CD Burning in VISTA [modified] Pin
User 21559730-Sep-09 0:57
User 21559730-Sep-09 0:57 
QuestionCrystal report color Pin
antala30-Sep-09 0:27
antala30-Sep-09 0:27 
AnswerRe: Crystal report color Pin
Christian Graus30-Sep-09 0:42
protectorChristian Graus30-Sep-09 0:42 
QuestionFind MIN value in binding? Pin
kanchoette30-Sep-09 0:02
kanchoette30-Sep-09 0:02 
QuestionThe type of a linq request Pin
teycir29-Sep-09 23:50
teycir29-Sep-09 23:50 
Hi;
I'm calling stored procedures using linq to sql to fill comboboxes from a database.
I have the method ConnectFilter() above that i want to refactor.
I started refactoring using FillComboWithData(ComboBox combo, string value, string display, DataClassesReferentielDataContext dc, XXXXX) above.
DataClassesReferentielDataContext is the Linq datacontext, it contains all the database mapped into objects.
By the way the stored procedures call many fields of many tables.
Here an example of a stored proc: P_ESS_Categorie_BIS.
I don't know how to enter the stored procedure as an argument (in place of XXXXX).
I think the argument should be an enumerable.
Thanks.


private DataClassesReferentielDataContext _dc = new DataClassesReferentielDataContext();
// The method I want to refactor
 private void ConnectFilter()
        {
            comboBoxCountryFilter.DataSource = _dc.P_ESS_Entite();
            comboBoxCountryFilter.ValueMember = "PAY_Code";
            comboBoxCountryFilter.DisplayMember = "PAY_Libelle";
            var statut = from s in _dc.TR_Statuts select s;
            comboBoxStatusFilter.DataSource = statut.ToArray();
            comboBoxStatusFilter.ValueMember = "STA_ID";
            comboBoxStatusFilter.DisplayMember = "STA_Libelle";
            comboBoxCategoryFilter.DataSource = _dc.P_ESS_Categorie_BIS((int) Selections.VueRefId);
            comboBoxCategoryFilter.ValueMember = "CAT_Code";
            comboBoxCategoryFilter.DisplayMember = "CAT_Libelle";
            comboBoxItPlanFilter.DataSource = _dc.P_ESS_ITPlan_BIS((int) Selections.VueRefId);
            comboBoxItPlanFilter.ValueMember = "ITP_Code";
            comboBoxItPlanFilter.DisplayMember = "ITP_Libelle";
            comboBoxGroupFilter.DataSource = _dc.P_ESS_GroupeProjet_BIS((int) Selections.VueRefId);
            comboBoxGroupFilter.ValueMember = "GRP_Code";
            comboBoxGroupFilter.DisplayMember = "GRP_Libelle";
            comboBoxSponsorFilter.DataSource = _dc.P_ESS_Sponsor_BIS((int) Selections.VueRefId);
            comboBoxSponsorFilter.ValueMember = "SPO_Code";
            comboBoxSponsorFilter.DisplayMember = "SPO_Libelle";
            comboBoxThemaFilter.DataSource = _dc.P_ESS_ThematiqueProjet_BIS((int) Selections.VueRefId);
            comboBoxThemaFilter.ValueMember = "THE_Code";
            comboBoxThemaFilter.DisplayMember = "THE_Libelle";
            comboBoxPersonFilter.DataSource = _dc.P_TR_Personne_Liste_Filtre();
            comboBoxPersonFilter.ValueMember = "PER_ID";
            comboBoxPersonFilter.DisplayMember = "PER_NomUT";
        }
 
 
// The refactoring
  private void FillComboWithData(ComboBox combo, string value, string display, DataClassesReferentielDataContext dc, XXXXX)
        {
            combo.DataSource = _dc.P_ESS_NatureProjet_BIS((int)Selections.VueRefId); // The proc call i want to enter as an argument of FillComboWithData
            combo.ValueMember = value.Trim();
            combo.DisplayMember = display.Trim();
        }


ALTER PROCEDURE  [dbo].[P_ESS_Categorie_BIS]  
	 @Vue_Referentiel numeric(10,0)
AS
BEGIN
 
SELECT [CAT_Code]
      ,[CAT_Libelle]
  FROM [TR_Categorie] 
WHERE     ([TR_Categorie].VUR_Id = @Vue_Referentiel) 
order by [CAT_Libelle]
END 

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.