public class CitiesList
{
public int cityId{ get; set; }
public int CountryId{ get; set; }
public string CITY { get; set; }
public List<CitiesList> GetCity()
{
//get city list
.
.
.
var query = from o in dsResult.Tables[0].AsEnumerable()
select new CitiesList
{
CITYID = o.Field<int>("CITYID"),
CITY = o.Field<string>("CITY")
};
List<CitiesList> lstDisplay = new List<CitiesList>();
lstDisplay.AddRange(query);
return lstDisplay;
}
}
public class CountriesList
{
public int CountryId { get; set; }
public string CountryName { get; set; }
public List<CountriesList> GetDisplayCountryList()
{
//code
.
.
var query = from o in dsResult.Tables[0].AsEnumerable()
select new CountriesList
{
CountryName = o.Field<string>("CountryName"),
CountryId = o.Field<int>("CountryId")
}
}
All this code is working well....Now what if i want a join query to display data from both tables?because i can assign data only to one list at a tyme?
Member
96 Points
386 Posts
Object Oriented Model Issue
Feb 16, 2012 08:15 AM|shafiqkr|LINK
i have two tables
1= cities(cityId,CITY(string) ,CountryId)
2= countries(Id,CountryName(string))
i have two classes
Member
96 Points
386 Posts
Re: Object Oriented Model Issue
Feb 29, 2012 01:44 AM|shafiqkr|LINK
can i get data to display from both tables?
Participant
834 Points
330 Posts
Re: Object Oriented Model Issue
Feb 29, 2012 01:53 AM|pratik_galoria|LINK
of course you can, dont set return type as a particular class of your function..keep it list only and join your tables with LINQ, like,
var type = from t1 in db.UserItems
join t2 in db.Items
on t1.ItemID equals t2.ID
where t1.ID == userItemID
select new { t1.ID, t2.CategoryType };
Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
Member
96 Points
386 Posts
Re: Object Oriented Model Issue
Feb 29, 2012 06:29 AM|shafiqkr|LINK
could not understand...please give me an example from my code above...
Participant
834 Points
330 Posts
Re: Object Oriented Model Issue
Feb 29, 2012 07:08 AM|pratik_galoria|LINK
refer this link
http://msdn.microsoft.com/en-us/library/bb386921.aspx
Software Engineer,
iGATE Global Solutions.
pratik_galoria@yahoo.co.in
+91-8905195943
Member
96 Points
386 Posts
Re: Object Oriented Model Issue
Feb 29, 2012 07:16 AM|shafiqkr|LINK
Actually i am using one class for one table fields.so creating list of that class..
Now how i will call and use other table fields in this one class ?
one storeprocedure returns only one table as dataset...i can not get this point