Click here to Skip to main content
15,903,385 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: get same parameter twice Pin
miss78620-Dec-13 10:06
miss78620-Dec-13 10:06 
GeneralRe: get same parameter twice Pin
miss78623-Dec-13 3:50
miss78623-Dec-13 3:50 
GeneralRe: get same parameter twice Pin
Richard Deeming6-Jan-14 8:35
mveRichard Deeming6-Jan-14 8:35 
GeneralRe: get same parameter twice Pin
miss7867-Jan-14 5:50
miss7867-Jan-14 5:50 
GeneralRe: get same parameter twice Pin
Richard Deeming7-Jan-14 8:03
mveRichard Deeming7-Jan-14 8:03 
GeneralRe: get same parameter twice Pin
miss7869-Jan-14 6:25
miss7869-Jan-14 6:25 
GeneralRe: get same parameter twice Pin
Richard Deeming9-Jan-14 7:50
mveRichard Deeming9-Jan-14 7:50 
GeneralRe: get same parameter twice Pin
miss78613-Jan-14 5:03
miss78613-Jan-14 5:03 
Hello, I would like to sincerely apologies for the confusion with my data parameters. i will try to explain the continuous issue I am currently experiencing with the 'split' function
as clearly and with
the requested classes and entities.

I would like to be able to call multiple 'name' and 'id1''s entities in a single call, such as api/test?name=storm,prest&id1=123. So far, I can get only get one of the parameter's (name or id1) to output multiple string values.
If I try to execute, the following with more than two parameters: api/test?name=storm,prest&id1=123, I get a 'no data error'.

This is my updated code:
please note: the split function has been updated for checking null strings in 'name' and 'ids' parameters.

C#
public HttpResponseMessage Get([FromUri] Query query)
        {
            var data = db.database_ICs.AsQueryable();

            if (!String.IsNullOrEmpty(query.name))
            {
                var ids = query.name.Split(',').ToList();                
                //data = data.Where(c => c.Name == query.name);
                data = data.Where(c => ids.Any(i => (c.Name!= null && c.Name.Contains(i))));
            }

            if (!String.IsNullOrEmpty(query.id1))
            {
                var ids = query.id1.Split(',').ToList();
                
                data = data.Where(c => ids.Any(i => (c.ID1!= null && c.ID1.Contains(i))));
                data = data.Where(c => c.Name == query.name);
            }

            if (!String.IsNullOrEmpty(query.id2))
            {
                var ids = query.id2.Split(',').ToList();

                //data = data.Where(c => ids.Any(i => (c.ID2!= null && c.ID2.Contains(i))));
                data = data.Where(c => c.ID2 == query.id2);
            }

            if (query.deal_type != null)
            {
                data = data.Where(c => c.Type == query.deal_type);
            }
            if (!data.Any())
            {
                var message = string.Format("No data was found");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
            }

            return Request.CreateResponse(HttpStatusCode.OK, data);
        }


public class Query
    {

        public string name { get; set; }
        public string id1{ get; set; }
        public string id2{ get; set; }
        public string deal_type { get; set; }
        
    }</pre>

Name	id1	id2	deal_type
prest	789		ms
prest	345		ms
storm		456	bs
storm			bs
ariel	123		rs
ariel		223	rs


Thank you so much your time and help. Many thanks.

GeneralRe: get same parameter twice Pin
Richard Deeming13-Jan-14 7:49
mveRichard Deeming13-Jan-14 7:49 
GeneralRe: get same parameter twice Pin
miss78614-Jan-14 5:08
miss78614-Jan-14 5:08 
GeneralRe: get same parameter twice Pin
Richard Deeming14-Jan-14 10:59
mveRichard Deeming14-Jan-14 10:59 
GeneralRe: get same parameter twice Pin
miss78628-Jan-14 6:52
miss78628-Jan-14 6:52 
QuestionWhat is the best way for managing reports in Kentico CMS 7.0 Pin
Bhushan Patki19-Dec-13 0:32
Bhushan Patki19-Dec-13 0:32 
Answertemp Pin
Ya Rasoolallah18-Dec-13 12:56
Ya Rasoolallah18-Dec-13 12:56 
SuggestionRe: temp Pin
Richard MacCutchan18-Dec-13 22:00
mveRichard MacCutchan18-Dec-13 22:00 
Questionauto complete with ajaxcontroltoolkit and ado.net Pin
Ya Rasoolallah18-Dec-13 12:01
Ya Rasoolallah18-Dec-13 12:01 
AnswerRe: auto complete with ajaxcontroltoolkit and ado.net Pin
thatraja18-Dec-13 13:39
professionalthatraja18-Dec-13 13:39 
GeneralRe: auto complete with ajaxcontroltoolkit and ado.net Pin
Ya Rasoolallah18-Dec-13 14:05
Ya Rasoolallah18-Dec-13 14:05 
GeneralRe: auto complete with ajaxcontroltoolkit and ado.net Pin
thatraja18-Dec-13 14:22
professionalthatraja18-Dec-13 14:22 
GeneralRe: auto complete with ajaxcontroltoolkit and ado.net Pin
Ya Rasoolallah19-Dec-13 6:10
Ya Rasoolallah19-Dec-13 6:10 
AnswerRe: auto complete with ajaxcontroltoolkit and ado.net Pin
joginder-banger25-Dec-13 15:36
professionaljoginder-banger25-Dec-13 15:36 
QuestionAre there any good "substitute" ASP.Net lessons for "C# for programmers 2e"? Pin
That New Guy18-Dec-13 10:47
That New Guy18-Dec-13 10:47 
AnswerRe: Are there any good "substitute" ASP.Net lessons for "C# for programmers 2e"? Pin
Rahul Rajat Singh19-Dec-13 18:23
professionalRahul Rajat Singh19-Dec-13 18:23 
AnswerRe: Are there any good "substitute" ASP.Net lessons for "C# for programmers 2e"? Pin
abdul subhan mohammed21-Dec-13 3:44
professionalabdul subhan mohammed21-Dec-13 3:44 
Questionpass a value from custom text box control to controller Pin
Member 1040952418-Dec-13 10:01
Member 1040952418-Dec-13 10:01 

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.