15,906,106 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by nik varma (Top 6 by date)
nik varma
15-Dec-16 8:04am
View
Hi Richard, Thank you for the reply, but i case there will be some location id null and it is giving a error message, for the reason Convert.ToInt16(l["Location_ID"]) is coming null
Please help with the same
nik varma
14-Dec-16 2:17am
View
Thanks Richard
I found the second way and i will try your solution if its not possible with the this solution
now i am able to got the same json format but issue is that i have added a rows in sublocation table and now when i am trying to get the json data all working fine but in location of sublocation all the sublocations are coming instend of respective location of sublocation
Please help, i guess m missing something
_gloc.country = _dt.AsEnumerable()
.GroupBy(c => new { country_id = c["country_id"], country_name = c["country_name"] })
.Select(co => new Country
{
country_id = Convert.ToInt16(co.Key.country_id.ToString()),
country_name = Convert.ToString(co.Key.country_name.ToString()),
location = co.Select(l => new Location()
{
name = l["Location_Name"].ToString(),
addedon = l.IsNull("Location_Addedon") ? (DateTime?)null : Convert.ToDateTime(l["Location_Addedon"]),
createdby = l["Location_CreatedBy"].ToString(),
id = l.IsNull("Location_ID") ? (int?)null : Convert.ToInt16(l["Location_ID"]),
location_lat = l["Location_Lat"].ToString(),
location_long = l["Location_Long"].ToString(),
sub_location = co
.Select(subl => new Sub_Location()
{
id = subl.IsNull("SubLocation_ID") ? (Int16?)null : Convert.ToInt16(subl["SubLocation_ID"]),
sublocation_name = subl["SubLocation_Name"].ToString(),
addedon = subl.IsNull("SubLocation_AddedOn") ? (DateTime?)null : Convert.ToDateTime(subl["SubLocation_AddedOn"].ToString())
}).Where(x => x.id != null).ToList()
}).Where(ll => ll.id != null).ToList()
}).ToList();
nik varma
9-Oct-16 12:24pm
View
Thanks David, please can you tell me how can i bind a data from database as i have mentioned the same in above how i am trying now.. Is this correct way, what i am trying?
nik varma
9-Oct-16 4:20am
View
Thanks friend, but here my key "EG00015588" is dynamic and may continent a space so how can i make a property of it and hold in List?
nik varma
9-Oct-16 0:03am
View
inside the class the their are two list, in which i want to bond the data, as shown in the property nested list, please check the output that i want
please help if you know
nik varma
5-Oct-16 11:12am
View
haha, yes
just found a link, but thank you so much and have given you a full rating :)
http://www.aspdotnet-suresh.com/2014/11/csharp-convert-datatable-to-generic-list-example-using-linq.html
Show More