Avatar of Olukayode Oluwole
Olukayode Oluwole
Flag for Canada asked on

How Can I resolve a LINQ Query Syntax

I have 2 Lists
1 Staff  List
2 Staff Variations List

I want be able to select a staff  and limit the entries in the variations List
to records for this staff  only. (see atached screen for the 2 Lists)

I have been able to select the staff and have shown the selected staff no N003  in the debugger

In trying to pass the value N003  to the LINQ  Query   I am having a syntax error

I have tried  to use Intellisense as far as possible but  somehow I have this syntax error
highlighted

Please  see  attached word file that gives a step by step activity  and all debugger values
including the syntax error  in the LINQ Query

I will appreciate any  input into how to get the LINQ Query  syntax right

Thanks

Oluwole
VariationsScreen08022019.PNG
SCRIPT-SELECT-STAFF-AND-LIMIT-STAFF.docx
LINQ QuerySQL

Avatar of undefined
Last Comment
Olukayode Oluwole

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Olukayode Oluwole

ASKER
Agreed.
I have now changed it (  to  == )   and tried again. The syntax error is now cleared but i noticed that
the records  i want are selected but the List  is empty. ( Nothing Displayed)

What i found out was that  under the click event  the script ran but left there and went to

 private void StaffNameListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            StaffVariationsList.DataSource = null;
            List<MonthlyVariationsModel> variationlist = GlobalConfig.Connection.GetAllVariationsThisperiod();
            variationlist = variationlist.Where(x => x.Staff_no == StaffNoParameter.Text).ToList();
            StaffVariationsList.DisplayMember = "StaffVariationList";
        }

which before did not have any code

So i copied the code  out from the Click event to the SelectedIndexChanged event.

The List Clears ( which is Line 1  but does not  display any records

The debugger  shows that  the 2 records i want are selected ( whether i click N001 or N003) BUT the List is not populated

What could be the problem ?

Olukay
Olukayode Oluwole

ASKER
I think the reason the List is not Displaying  is that the item to display are in variationlist

whereas  the List name is StaffVariationsList

How can i assign the contents of  variationlist to StaffVariationsList

Regards

Olukay
Bill Prew

Your original question has been answered, and your new question is a bit more involved I suspect.  I would recommend you close this question selecting any solutions that worked, and post a new question, including more of you application code so that experts can get a better sense of what all is going on.


»bp
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Olukayode Oluwole

ASKER
Thanks  for the effort