I have two tables... ITEM and STOREITEM
ITEM columns --ITMID_PK,ITMNAME, description ,iCON
STOREITEM columns --ITMID_FK,PRICE
to retrieve data of ITEM table to list and store in listbox. I follow this
List<ITEM> retrievedlist = sqlconn.query<ITEM>("select * from ITEM").ToList<ITEM>();
foreach (var t in retrievedlist )
{
listbox.Items.Add(t);
}
this works perfectly for single table
Now I need to perform INNER JOIN in code behind(c#) for this two tables..
what i have tried is..
List<STOREITEM> retrievedlist = sqlconn.Query<STOREITEM>("select ITEM.ITMNAME,ITEM.ICON,STOREITEM.PRICE FROM ITEM INNER JOIN STOREITEM ON ITEM.ITMID_PK=STOREITEM.ITMID_FK ORDER BY ITMNAME").ToList<STOREITEM>();
it returns only STOREITEM based columns ,as we are giving STOREITEM besides query method..
so i tried this too
List<ITEM> retrievedlist = sqlconn.Query<ITEM>("select ITEM.ITMNAME,ITEM.ICON,STOREITEM.PRICE FROM ITEM INNER JOIN STOREITEM ON ITEM.ITMID_PK=STOREITEM.ITMID_FK ORDER BY ITMNAME").ToList<ITEM>();
it returns only ITEM based columns... even though query method.. has INNER join query
the following one wont work ,as it has invalid parameters in Query method(two table names given as class inside query<>)
List<ITEM,STOREITEM> retrievedlist = sqlconn.Query<ITEM>("select ITEM.ITMNAME,ITEM.ICON,STOREITEM.PRICE FROM ITEM INNER JOIN STOREITEM ON ITEM.ITMID_PK=STOREITEM.ITMID_FK ORDER BY ITMNAME").ToList<ITEM>();
please help me with this.. the queried data should be stored in list and then that list should added as items to listbox.. any help is appreciated...
Aucun commentaire:
Enregistrer un commentaire