Easy Question - Query EntityCollection

Posts   
 
    
BringerOD
User
Posts: 70
Joined: 15-Jul-2006
# Posted on: 16-Jul-2006 22:12:00   

I figured it out! simple_smile


The following code gives me an error asking me for a IRelationPredicateBucket. The problem is there is none. Of course if I put nothing there it give me all the records. I dont want them all. Basically all I am trying to do is query the "LocalizedControls" table with a simple where clause.

To say it differently, I am not filling the EntityCollection by another entity or another relation.

I want to do this.

Select * from LocalizedControls Where Position = 1 and ValueType = 1 and LanguageObjectId = 123

But I can't seem to find an example.

Sorry for the dumb questions.

Below is my attempt. I have replace the lFilter with nothing and I do get all the records. Now I just need to add some where clause.

Again, sorry I am new.

        

        Dim lLocalizeControls As New EntityCollection(New LocalizedControlsEntityFactory)
        Dim lAdapter As New DataAccessAdapter

        Dim lFilter As New PredicateExpression

        lFilter.Add(LocalizedControlsFields.ValueType = 1)
        lFilter.AddWithAnd(LocalizedControlsFields.Position = 1)
        lFilter.AddWithAnd(LocalizedControlsFields.LanguageObjectId = 123)

        lAdapter.FetchEntityCollection(lLocalizeControls, lFilter)

        Me.DataGridView1.DataSource = lLocalizeControls