Click here to Skip to main content
15,899,313 members
Home / Discussions / Database
   

Database

 
QuestionSQL Linq, concepts of writing queries Pin
jkirkerx8-Jul-15 8:55
professionaljkirkerx8-Jul-15 8:55 
So I got my experimental code in VB working now, and a basic query.
So I'm looking at my original code, in which I sort of pieced together a query.
e.g.
Dim query As String = _
"SELECT *  FROM MOVIEINFO "

Select Case p_Type
Case "FLV"
 query += " WHERE flv = 1 "
Case "H264"
  query += " WHERE h264 = 1 "
End Select

Select Case p_Sort
Case "NAME"
  query += " ORDER BY MovieName "
Case "TYPE"
  query += " ORDER BY MovieType "
End Select

Now I'm seeing if I can do the same thing in Linq
So this is my simple query. I'm not quite sure how to sort of do the same thing in the sample below.
I'm aware that I can load all the records into pResults, and then do another query to further isolate the results, but that doesn't seem efficient. I really just want to get the records of type, and a start and stop range. In other words, this is a indexed page of movies, and you click the page number to show those results. I already have the start and stop values.

Any input that is sound would be appreciated, Thanks
pResults =
            (From item In context.Movies
             Where item.flv = True
             Order By item.MovieName
            Select New MovieItem With
            {
                .MovieID = item.MovieID,
                .MovieName = item.MovieName,
                .MovieType = item.MovieType,
                .MovieDeliveryType = item.MovieDeliveryType,
                .MoviePath = item.MoviePath,
                .MovieUrl = item.MovieURL,
                .MoviePostage = item.MoviePostage,
                .MovieThumbnail = item.MovieThumbnail,
                .MovieLarge = item.MovieLarge,
                .MoviePlaceHolder = item.MoviePlaceHolder,
                .MovieBitRate = item.MovieBitRate,
                .MovieTime = item.MovieTime,
                .MovieSize = item.MovieSize,
                .MovieDescription = item.MovieDescription,
                .MovieCount = item.MovieCount,
                .MovieContributor = item.MovieContributor,
                .MoviePostDate = item.MoviePostDate,
                .MovieIcon = item.MovieIcon,
                .MovieParameters = item.movie_Parameters
        }).AsEnumerable

AnswerRe: SQL Linq, concepts of writing queries Pin
Richard Deeming8-Jul-15 10:46
mveRichard Deeming8-Jul-15 10:46 
GeneralRe: SQL Linq, concepts of writing queries Pin
jkirkerx8-Jul-15 12:32
professionaljkirkerx8-Jul-15 12:32 
Questionssrs rendering format ppt pptx Pin
Aurelkb5-Jul-15 23:35
Aurelkb5-Jul-15 23:35 
AnswerRe: ssrs rendering format ppt pptx Pin
Richard MacCutchan6-Jul-15 0:13
mveRichard MacCutchan6-Jul-15 0:13 
QuestionEvaluate returnvalues of stored procedures used in TableAdapterManager.UpdateAll Pin
atrus27113-Jul-15 1:49
atrus27113-Jul-15 1:49 
AnswerRe: Evaluate returnvalues of stored procedures used in TableAdapterManager.UpdateAll Pin
atrus27113-Jul-15 2:39
atrus27113-Jul-15 2:39 
QuestionOracle Query Builder Pin
Mycroft Holmes30-Jun-15 14:18
professionalMycroft Holmes30-Jun-15 14:18 
AnswerRe: Oracle Query Builder Pin
Jörgen Andersson7-Jul-15 8:40
professionalJörgen Andersson7-Jul-15 8:40 
QuestionEntity Framework 6.0.3 problem Pin
Mark Miller24-Jun-15 10:42
Mark Miller24-Jun-15 10:42 
AnswerRe: Entity Framework 6.0.3 problem Pin
Mark Miller1-Jul-15 9:49
Mark Miller1-Jul-15 9:49 
Questionstop accessing peoples SQL server through SQL management Studio. Pin
Azam Niaz Ch.21-Jun-15 9:06
Azam Niaz Ch.21-Jun-15 9:06 
AnswerRe: stop accessing peoples SQL server through SQL management Studio. Pin
PIEBALDconsult21-Jun-15 9:24
mvePIEBALDconsult21-Jun-15 9:24 
GeneralRe: stop accessing peoples SQL server through SQL management Studio. Pin
Azam Niaz Ch.21-Jun-15 18:21
Azam Niaz Ch.21-Jun-15 18:21 
GeneralRe: stop accessing peoples SQL server through SQL management Studio. Pin
PIEBALDconsult21-Jun-15 18:28
mvePIEBALDconsult21-Jun-15 18:28 
GeneralRe: stop accessing peoples SQL server through SQL management Studio. Pin
scottgp22-Jun-15 1:19
professionalscottgp22-Jun-15 1:19 
GeneralRe: stop accessing peoples SQL server through SQL management Studio. Pin
Eddy Vluggen22-Jun-15 1:36
professionalEddy Vluggen22-Jun-15 1:36 
AnswerRe: stop accessing peoples SQL server through SQL management Studio. Pin
Mycroft Holmes21-Jun-15 19:57
professionalMycroft Holmes21-Jun-15 19:57 
AnswerRe: stop accessing peoples SQL server through SQL management Studio. Pin
GuyThiebaut21-Jun-15 21:24
professionalGuyThiebaut21-Jun-15 21:24 
GeneralRe: stop accessing peoples SQL server through SQL management Studio. Pin
Mycroft Holmes22-Jun-15 14:13
professionalMycroft Holmes22-Jun-15 14:13 
QuestionMaximum stored procedure, function, trigger, or view nesting level exceeded (limit 32) Pin
indian14319-Jun-15 15:46
indian14319-Jun-15 15:46 
AnswerRe: Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32) Pin
Richard Deeming22-Jun-15 1:41
mveRichard Deeming22-Jun-15 1:41 
GeneralRe: Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32) Pin
indian14322-Jun-15 7:00
indian14322-Jun-15 7:00 
QuestionHow to add primary key in existing table? Pin
apple blue16-Jun-15 16:53
apple blue16-Jun-15 16:53 
AnswerRe: How to add primary key in existing table? Pin
Peter Leow16-Jun-15 17:07
professionalPeter Leow16-Jun-15 17:07 

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.