Calling a function within Entity Framework Select

entity-framework entity-framework-6 linq-to-entities vb.net

Question

A characteristic of my object (oJobs ) is the following:

    Private _brandlist As List(Of DAL.Brand)
    Public Property PostBrandList() As List(Of DAL.Brand)
        Get
            Return _brandlist
        End Get
        Set(ByVal value As List(Of DAL.Brand))
            _brandlist = value
        End Set
    End Property

The brand list is kept in the database as a series of numbers separated by commas, such as the string "3,45,2" in the column labeled "brands," where each number is an identification number for a brand kept in a different table.

Here is my select query:

Dim jobposts As List(Of oJobs) = From j In db.JobPostings
Select New oJobs With {                                                                  'hiding all others for code brevity
    .PostBrandList = 'problem is here'
}

Since j.BrandList will return a string, which I must break into separate queries for each number to get the final result and assign it to a List(Of).DAL.Brand ) into.PostBrandList

Whoever could inquire, "What have you tried?"

  • After running the query, I added the list of brands using a for each loop, which was successful but not ideal.
  • I foolishly built a function that accepts a list as a parameter and returns a different list of objects.

I am also prohibited from normalizing the database: (

1
0
3/13/2015 3:44:26 AM

Popular Answer

Maybe you just want to split the column brands into an array using the Split method, then loop through the result and extract the brand objects with the Find function?

0
3/19/2015 2:30:48 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow