query not returning all requested fields  Topic is solved

Discussions relating to the REST API of Jiwa 7.

query not returning all requested fields

Postby JuiceyBrucey » Wed Mar 10, 2021 6:03 pm

Hi,
I have attached the API XML.
I have looked at autoquery and it does the job for some of my questions, however I have not been able to find info on specifying table joins from the URL.
So I have used plain SQL.
SELECT
main.LastSavedDateTime,
main.InventoryID,
main.PartNo,
main.Description,
main.Status,
main.DefaultPrice,
main.RRPPrice,
main.Aux2,
main.BackOrderable,

price.InventoryID,
price.Price1,
price.Price2,
price.Price3,
price.Price4,
price.Price5

FROM IN_Main main
LEFT JOIN
IN_SellingPrices price
ON
price.InventoryID=main.InventoryID
ORDER BY main.InventoryID
OFFSET @StartPosition
ROWS FETCH NEXT @NumberRows
ROWS ONLY;

The problem is, it only returns the table fields from the IN_Main table, not from the IN_SellingPrices table. I need all of the fields requested in the SQL.
How can I get these fields returned as well?
Cheers
Attachments
Plugin REST API get inventory, limit fields, specify start and finish.xml
(25.11 KiB) Downloaded 41 times
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: query not returning all requested fields  Topic is solved

Postby Mike.Sheen » Wed Mar 10, 2021 6:18 pm

Moved to REST API forum from SQL Server forum.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: query not returning all requested fields

Postby Mike.Sheen » Wed Mar 10, 2021 6:21 pm

Because you're now returning something which isn't a list of IN_Main, you just need to create your own custom class with the properties matching the SQL columns.

Import the attached plugin (Open Plugin maintenance and select Import XML from the Utilities tab of the ribbon), save and restart your service - it should be as you expect now.

Mike
Attachments
Plugin REST API get inventory, limit fields, specify start and finish - custom model.xml
(26.76 KiB) Downloaded 54 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: query not returning all requested fields

Postby JuiceyBrucey » Wed Mar 10, 2021 7:25 pm

Perfect. Thanks so much for that.
From what you have seen me ask, what do you think I should be focusing on as far as tutorials and learning?
I need to get on top of this so that I am not constantly asking questions.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: query not returning all requested fields

Postby Mike.Sheen » Wed Mar 10, 2021 9:09 pm

JuiceyBrucey wrote:From what you have seen me ask, what do you think I should be focusing on as far as tutorials and learning?
I need to get on top of this so that I am not constantly asking questions.


It's hard to answer this without knowing what you are trying to achieve - which would infer would you would need to know - and also what you already know.

You've achieved creating a custom route which returns a custom shaped result set which accepts parameters - for REST API development that's going to be a rather large part of any project - so at least that's out of the way!

As I think you're building a web store integration, the remaining aspect typically is creating and updating sales orders in Jiwa - and we already have comprehensive coverage in our API for that out of the box - so it doesn't leave much left for you to worry about.

Perhaps I can better answer your question if you list off brief bullet points on what you need to achieve.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: query not returning all requested fields

Postby JuiceyBrucey » Thu Mar 11, 2021 6:57 am

Hi,
Yes, I am building an integration between JIWA and a custom CMS. So anything related to that is important.
My current abilities are mostly related to PHP, MySQL, HTML, Javascript, REGEX and other minor stuff. I build custom content managements systems from the ground up. It is a niche that I have cracked.
But I really like the idea of being able to make integrations between JIWA and my CMS. I would at a later date like to build desktop apps that integrate with my CMS.
But I have a long way to go with that.

So just on the last issue discussed, and particularly this part:
#region "Responses"
[Serializable()]
public class InventoryLimitFieldsResponse : List<MyCustomModel>
{
}
#endregion

#region "Models"
public class MyCustomModel
{
public DateTime LastSavedDateTime { get; set; }
public string InventoryID { get; set; }
public string PartNo { get; set; }
public string Description { get; set; }
public int Status { get; set; }
public decimal DefaultPrice { get; set; }
public decimal RRPPrice { get; set; }
public string Aux2 { get; set; }
public bool BackOrderable { get; set; }
public decimal Price1 { get; set; }
public decimal Price2 { get; set; }
public decimal Price3 { get; set; }
public decimal Price4 { get; set; }
public decimal Price9 { get; set; }
}
#endregion

I need to know more about this. The how, the why, construction of this and how it relates to this:
Db.SqlList<MyCustomModel>
Should I focus on core C#, or ServiceStack, or ORMLite, or all three?
Which one would you prioritise for now?
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: query not returning all requested fields

Postby Mike.Sheen » Thu Mar 11, 2021 11:55 am

JuiceyBrucey wrote:Should I focus on core C#, or ServiceStack, or ORMLite, or all three?


All three, with C# as the priority - particularly the topic of generics.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: query not returning all requested fields

Postby SBarnes » Tue Mar 16, 2021 10:35 pm

This is a little bit old but I found it a good intro to ServiceStack

https://www.syncfusion.com/ebooks/servicestack
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 3 guests