Yes try creating a plugin....Try retrieving activity records using linq, for this you will need crm svcutil so generate that file.
//Retrieve license data that match with state and line of business in lead entity
var query = from l in servicecontext.biz_licenseSet
where (l.biz_State == leadstate) && (l.biz_LOBId.Id == lob.Id)
select l;