This is a migrated thread and some comments may be shown as answers.

[Solved] Retrieving a specific row?

1 Answer 128 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Derek
Top achievements
Rank 1
Derek asked on 18 Dec 2013, 07:27 PM
Evaluating the OpenAccess ORM, but some things aren't clear. I'm sure this is simple, but I just don't get it.

We are trying to retrieve a specific row from a table (FrequencyTypes), using the a value which is the PK. What we'd like to do is retrieve a row into a variable, and then use the values to do a few things.
Using dbContext As New EntitiesModel
            Dim lFreq As New FrequencyType
            lFreq=dbContext.FrequencyTypes.????[what goes here?]
end using
The context is being resolved property, as we're able to perform other actions, but not sure how to go about this.

1 Answer, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 20 Dec 2013, 08:23 AM
Hello Derek,

In order to retrieve a single row from the OpenAccess context in accordance with given criteria you could use one of the following LINQ methods First, FirstOrDefault, Single or SingleOrDefault.
Here is an example of this approach:
Dim context = New EntitiesModel1()
Using context
    Dim primaryKeyValue As Integer = GetPrimaryKey()
    Dim retrievedRow = context.FrequencyTypes.FirstOrDefault(Function(x) x.Id = primaryKeyValue)
End Using

More on how to use OpenAccess ORM with LINQ can be found in this documentation section. Additionally I would recommend looking through our Samples Kit which provides a number of real-life examples including working with LINQ.

Do not hesitate to contact us in case you have any further questions.

Regards,
Boyan
Telerik
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Tags
Data Access Free Edition
Asked by
Derek
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Share this question
or