Click here to Skip to main content
16,009,640 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Connect to remote sql server Pin
Richard Deeming10-Jul-15 1:52
mveRichard Deeming10-Jul-15 1:52 
QuestionHow to Call Stored Procedure parameters in Class Pin
Mohamed Hamdy9-Jul-15 14:42
Mohamed Hamdy9-Jul-15 14:42 
QuestionRe: How to Call Stored Procedure parameters in Class Pin
Ralf Meier9-Jul-15 20:29
mveRalf Meier9-Jul-15 20:29 
AnswerRe: How to Call Stored Procedure parameters in Class Pin
Mohamed Hamdy10-Jul-15 6:23
Mohamed Hamdy10-Jul-15 6:23 
QuestionRe: How to Call Stored Procedure parameters in Class Pin
Eddy Vluggen10-Jul-15 7:10
professionalEddy Vluggen10-Jul-15 7:10 
AnswerRe: How to Call Stored Procedure parameters in Class Pin
Wendelius10-Jul-15 7:18
mentorWendelius10-Jul-15 7:18 
AnswerRe: How to Call Stored Procedure parameters in Class Pin
Eddy Vluggen9-Jul-15 23:07
professionalEddy Vluggen9-Jul-15 23:07 
QuestionRun time Error Can't find project Library, Missing Reference attachemat Extra '0.9 Pin
Member 117214498-Jul-15 20:14
Member 117214498-Jul-15 20:14 
AnswerRe: Run time Error Can't find project Library, Missing Reference attachemat Extra '0.9 Pin
RedDk9-Jul-15 6:52
RedDk9-Jul-15 6:52 
QuestionData Access Layer, returning data Pin
jkirkerx6-Jul-15 12:33
professionaljkirkerx6-Jul-15 12:33 
AnswerRe: Data Access Layer, returning data Pin
Dave Kreskowiak7-Jul-15 9:36
mveDave Kreskowiak7-Jul-15 9:36 
GeneralRe: Data Access Layer, returning data Pin
jkirkerx7-Jul-15 10:40
professionaljkirkerx7-Jul-15 10:40 
GeneralRe: Data Access Layer, returning data Pin
Dave Kreskowiak7-Jul-15 10:50
mveDave Kreskowiak7-Jul-15 10:50 
GeneralRe: Data Access Layer, returning data Pin
jkirkerx7-Jul-15 11:20
professionaljkirkerx7-Jul-15 11:20 
GeneralRe: Data Access Layer, returning data Pin
jkirkerx7-Jul-15 11:27
professionaljkirkerx7-Jul-15 11:27 
GeneralRe: Data Access Layer, returning data Pin
Dave Kreskowiak7-Jul-15 14:54
mveDave Kreskowiak7-Jul-15 14:54 
jkirkerx wrote:
I have to project the results into another object like a class or something, to transport it.

You don't have to but it makes your code easier to understand, debug and support.

jkirkerx wrote:
I thought that's what the model was for

You can return just the model objects. It appears as though you're just returning every field of the Movie table, so you can just return an IEnumerable(Of Movie) instead of projecting into another object.

VB
Public Shared Function GetAllFlvMovies() As IEnumerable(Of Movie)
    Using context As New MovieContext()
        Dim results = From m In context.Movies
                      Where item.flv = 1
                      Order By m.MovieName
                      Select m
 
        Return results.AsEnumerable()
    End Using
End Function


Projection comes in handy when you are building view model objects. You only put the data you need into the view model object and possibly more data that isn't related to the database to supply your edit controls with.

VB
...
    Dim movies = From item In GetAllFlvMovies()
                 Select New MovieViewModel With
                 {
                     Id = item.MovieId,
                     Name = item.MovieName,
                     ...
                 }

    ... send the <code>movies</code> collection to whatever view you need ...

A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Data Access Layer, returning data Pin
jkirkerx8-Jul-15 12:46
professionaljkirkerx8-Jul-15 12:46 
GeneralRe: Data Access Layer, returning data Pin
Dave Kreskowiak8-Jul-15 14:56
mveDave Kreskowiak8-Jul-15 14:56 
AnswerRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
jkirkerx7-Jul-15 14:04
professionaljkirkerx7-Jul-15 14:04 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
Dave Kreskowiak7-Jul-15 15:09
mveDave Kreskowiak7-Jul-15 15:09 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
jkirkerx8-Jul-15 6:45
professionaljkirkerx8-Jul-15 6:45 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
jkirkerx8-Jul-15 7:40
professionaljkirkerx8-Jul-15 7:40 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
Dave Kreskowiak8-Jul-15 9:58
mveDave Kreskowiak8-Jul-15 9:58 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
jkirkerx8-Jul-15 10:37
professionaljkirkerx8-Jul-15 10:37 
GeneralRe: Data Access Layer, How to get the count, and use the data returned by the first function posted above Pin
Dave Kreskowiak8-Jul-15 11:15
mveDave Kreskowiak8-Jul-15 11:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.