Click here to Skip to main content
15,886,110 members
Home / Discussions / Database
   

Database

 
GeneralRe: Some help with SQL to Linq Conversions Pin
Richard Deeming13-Jul-15 8:00
mveRichard Deeming13-Jul-15 8:00 
QuestionSQL Linq, query and then take result to query again Pin
jkirkerx10-Jul-15 7:43
professionaljkirkerx10-Jul-15 7:43 
Answer[Solved] Pin
jkirkerx10-Jul-15 8:53
professionaljkirkerx10-Jul-15 8:53 
QuestionSELECT then INSERT data in a matrix way Pin
Farhad Eft9-Jul-15 9:14
Farhad Eft9-Jul-15 9:14 
AnswerRe: SELECT then INSERT data in a matrix way Pin
Richard Deeming9-Jul-15 9:22
mveRichard Deeming9-Jul-15 9:22 
GeneralRe: SELECT then INSERT data in a matrix way Pin
Farhad Eft9-Jul-15 10:51
Farhad Eft9-Jul-15 10:51 
QuestionSQL Linq, concepts of writing queries Pin
jkirkerx8-Jul-15 8:55
professionaljkirkerx8-Jul-15 8:55 
AnswerRe: SQL Linq, concepts of writing queries Pin
Richard Deeming8-Jul-15 10:46
mveRichard Deeming8-Jul-15 10:46 
Something like this should work:
VB.NET
Dim movies As IQueryable(Of Movie) = context.Movies

' Filter by type:
Select Case p_Type
    Case "FLV"
        movies = movies.Where(Function(m) m.flv)
    Case "H264"
        movies = movies.Where(Function(m) m.h264)
End Select

' Sort in the desired order:
Select Case p_Sort
    Case "NAME"
        movies = movies.OrderBy(Function(m) m.MovieName)
    Case "TYPE"
        movies = movies.OrderBy(Function(m) m.MovieType)
End Select

' Get a single page of data:
movies = movies.Skip(pageIndex * pageSize).Take(pageSize)

' Project the results:
pResults = movies.AsEnumerable().Select(Function(item) 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
    })

Assuming MovieItem isn't an entity type, you'll need the AsEnumerable call before the Select call.

Everything prior to the AsEnumerable call will be translated into a SQL query.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


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 

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.