public bool IsChannelMappedToCard(Channel dbChannel, Card card, bool forEpg)
{
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelMap));
SqlStatement origStmt = sb.GetStatement(true);
string sql = "select cm.* from ChannelMap cm where cm.idChannel =" +
dbChannel.IdChannel + " and cm.idCard=" + card.IdCard + (forEpg ? "" : " and cm.epgOnly=0");
SqlStatement statement = new SqlStatement(StatementType.Select, origStmt.Command, sql,
typeof (Channel));
IList<ChannelMap> maps = ObjectFactory.GetCollection<ChannelMap>(statement.Execute());
return maps != null && maps.Count > 0;
}