public static DataTable GetAllFreeFor(int itemID) { string query = String.Format("select (st.Prefix + ' ' + pl.Label) as PalletLocationName , * from PalletLocation pl join StorageType st on pl.StorageTypeID = st.ID join ItemPrefferedLocation ipl on ipl.PalletLocationID = pl.ID where ipl.ItemID = {0} and pl.PalletID is null", itemID); PalletLocation pl = new PalletLocation(); pl.LoadFromRawSql(query); if (pl.RowCount == 0) { Items itm = new Items(); itm.LoadByPrimaryKey(itemID); return PalletLocation.GetAllFree(itm.StorageTypeID.ToString()); } return pl.DataTable; }