Click here to Skip to main content
15,891,033 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Asp.net Pin
Ahmed Bensaid12-Feb-14 22:41
professionalAhmed Bensaid12-Feb-14 22:41 
QuestionBuilt in authentication Pin
larsp7776-Feb-14 1:41
larsp7776-Feb-14 1:41 
AnswerRe: Built in authentication Pin
Richard Deeming6-Feb-14 1:57
mveRichard Deeming6-Feb-14 1:57 
GeneralRe: Built in authentication Pin
larsp7776-Feb-14 2:00
larsp7776-Feb-14 2:00 
GeneralRe: Built in authentication Pin
Ali Al Omairi(Abu AlHassan)6-Feb-14 2:32
professionalAli Al Omairi(Abu AlHassan)6-Feb-14 2:32 
GeneralRe: Built in authentication Pin
Richard Deeming6-Feb-14 2:38
mveRichard Deeming6-Feb-14 2:38 
GeneralRe: Built in authentication Pin
joginder-banger6-Feb-14 4:27
professionaljoginder-banger6-Feb-14 4:27 
QuestionASP.NET MVC Web API - filter query with pagesize Pin
miss7865-Feb-14 22:39
miss7865-Feb-14 22:39 
Hello,

If I search (api/test/cusip=00163&isin=555), I get 10 records showing both of cusip and isin value and 9 records with price_type= cr and 1 record price_type= tk.

However, if I run the following query (api/test?cusip=00163&isin=555&price_type=cr), i only get results from cusip parameters (00163) and nothing from isin and they are also not in a descending order.

This is what I have so far:
C#
public HttpResponseMessage Get([FromUri] Query query)
        {
            var data = db.database.AsQueryable();

            int pageSize = 10;

            if (query.price_type != null)
            {
                data = data.Where(c => c.Cover == query.price_type);
            }
            
            int total = data.Count();
            // If any other filters are specified, return records which match any of them:
            var filteredData = new List<IQueryable<database_BWICs>>();

            if (!string.IsNullOrEmpty(query.isin))
            {
                var ids = query.isin.Split(',');
                foreach (string i in ids)
                {
                    filteredData.Add(data.Where(c => c.ISINs != null && c.ISINs.Contains(i)));
                }
            }

            if (!string.IsNullOrEmpty(query.cusip))
            {
                var ids = query.cusip.Split(',');
                foreach (string i in ids)
                {
                    filteredData.Add(data.Where(c => c.CUSIP != null && c.CUSIP.Contains(i)));
                }
            }


            // If no filters passed, return all data.
            // Otherwise, combine the individual filters using the Union method
            // to return all records which match at least one filter.
            
            if (filteredData.Count != 0)
            {
                data = filteredData.Aggregate(Queryable.Union).OrderByDescending(c => c.UploadDate).Take(pageSize);
            }

           
            if (!data.Any())
            {
                var message = string.Format("No data was found");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
            }

            if (query.price_type != null)
            {
                data = data.OrderByDescending(c => c.Cover == query.price_type).Take(pageSize);
            }
            

            //return Request.CreateResponse(HttpStatusCode.OK, data);
            return Request.CreateResponse(HttpStatusCode.OK, new { total, data });
        }
    }


I have tried debugging the issue many times on the following line with search string - http://localhost:32118/api/test?cusip=00163&isin=555&price_type=cr . The application crashes on the data parameter "data = {System.Data.Entity.DbSet<multi.database>} ". I am little unclear what this issue mean?

C#
if (query.price_type != null)
            {
                data = data.Where(c => c.Cover == query.price_type);
            }


Am I missing something? if so, is their a better way to do this? Thanks in advance for your help and time.

modified 7-Feb-14 5:28am.

AnswerRe: filter query with pagesize Pin
Ali Al Omairi(Abu AlHassan)6-Feb-14 1:55
professionalAli Al Omairi(Abu AlHassan)6-Feb-14 1:55 
GeneralRe: filter query with pagesize Pin
miss7866-Feb-14 23:27
miss7866-Feb-14 23:27 
GeneralRe: filter query with pagesize Pin
Ali Al Omairi(Abu AlHassan)7-Feb-14 11:25
professionalAli Al Omairi(Abu AlHassan)7-Feb-14 11:25 
GeneralRe: filter query with pagesize Pin
miss78610-Feb-14 0:37
miss78610-Feb-14 0:37 
QuestionTelerik grid vs. Kendo grid and Ajax calls Pin
littleGreenDude5-Feb-14 8:36
littleGreenDude5-Feb-14 8:36 
AnswerRe: Telerik grid vs. Kendo grid and Ajax calls Pin
littleGreenDude7-Feb-14 3:10
littleGreenDude7-Feb-14 3:10 
QuestionRDLC Report Designing Pin
Dnyaneshwar@Pune5-Feb-14 0:48
Dnyaneshwar@Pune5-Feb-14 0:48 
SuggestionRe: RDLC Report Designing Pin
Zohaib Asad11-Feb-14 21:13
Zohaib Asad11-Feb-14 21:13 
QuestionQuestion Event does not run when I click image that has event attached to it Pin
versm1ca4-Feb-14 22:21
versm1ca4-Feb-14 22:21 
AnswerRe: Question Event does not run when I click image that has event attached to it Pin
Deflinek5-Feb-14 0:48
Deflinek5-Feb-14 0:48 
GeneralRe: Question Event does not run when I click image that has event attached to it Pin
versm1ca5-Feb-14 7:19
versm1ca5-Feb-14 7:19 
GeneralRe: Question Event does not run when I click image that has event attached to it Pin
Richard Deeming5-Feb-14 8:15
mveRichard Deeming5-Feb-14 8:15 
GeneralCLOSED --- Re: Question Event does not run when I click image that has event attached to it Pin
versm1ca5-Feb-14 14:00
versm1ca5-Feb-14 14:00 
Questionradiobuttonlist change event with javascript Pin
ptvce4-Feb-14 1:21
ptvce4-Feb-14 1:21 
QuestionFlash Banner in Mobile asp.net Pin
Fcode-20143-Feb-14 21:28
Fcode-20143-Feb-14 21:28 
QuestionIf else structure problem Pin
Hunain Hafeez3-Feb-14 18:44
Hunain Hafeez3-Feb-14 18:44 
AnswerRe: If else structure problem Pin
Kornfeld Eliyahu Peter3-Feb-14 20:17
professionalKornfeld Eliyahu Peter3-Feb-14 20:17 

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.