سؤال

when i try to query database to retrive activity for selected crew, i give "Loca Sequence Error"

this is the code:

private Lst_active as new entityset(of Activity)   
private crw_list as new entityset(of Crew)

checklistbox.Items.addrange(Dbase.Crew)

then i choose from all crew in checklistbox and selected crews insert into entityset of Crew for further use.

crw_list.addrange(Checkedlistbox.checkeditems)

Lst_active.AddRange(From x In DBase.Stored_Activities Join z In crw_list On x.EMP_NO  Equals z.EMP_NO
                    Select x)

is there any way around? or im doing it wrong?

هل كانت مفيدة؟

المحلول 2

i find the solution, just changed place of two parts of query.

     From z In crw_list Join x In DBase.Stored_Activities  On x.EMP_NO  Equals z.EMP_NO
                Select x

it changes query from linq to sql to linq to object with a sql join query included.

نصائح أخرى

You haven't said how your model looks like, but following concept should work:

Dim active = (From x In DBase.Stored_Activities
              Join z In DBase.Stored_Crews On x.EMP_NO  Equals z.EMP_NO
              Select x).ToList()

Update

If you have a local in-memory collection and you need items with a field matching one within that collection, use Contains instead:

From x in DBase.StoredActivities
Where localList.Contains(x.EMP_NO)
select x

Your list should contain the joining column* only, in this case should be made from crw_list.Select(Function(x) x.EMP_NO).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top