using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ImportFootballResults;
namespace Analyze
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
}
public Program()
{
int[] seasons = new int[] { 2006, 2007, 2008, 2009, 2010};
// LINQ to SQL context (db conn)
ResultsDBDataContext db = new ResultsDBDataContext();
// write out a header
Console.WriteLine("Season, League, matches, qualified, qualified% ,0-0@HT, SR%");
// get all the leagues
var leagues = from l in db.Leagues
orderby l.ShortName, l.Div
select l;
// loop the leagues
foreach (var l in leagues)
{
// Loop seasons
for (int i = 0; i < seasons.Length; i++)
{
// get all games for a season+league
var games = from g in db.Results
where g.Div == l.ShortName
&& g.Season == seasons[i]
select g;
// games that qualifies
var o25qualifiers = from ou in games
where ou.BbAv_o25 < 2
select ou;
// games that are 0-0 at HalfTime
var scoreless = from s in o25qualifiers
where s.HTHG == 0 && s.HTAG == 0
select s;
// qualifier rate
float qrate = ((o25qualifiers.Count() / (float)games.Count()) * 100);
string qpercentage = String.Format("{0:0}", qrate);
// hit rate
float strikerate = 100-((scoreless.Count() / (float)o25qualifiers.Count())*100);
string srpercentage = String.Format("{0:0}", strikerate);
// write out the results
Console.WriteLine("{0}, {1}, {2}, {3}, {4}%, {5}, {6}%", seasons[i], l.Name, games.Count(), o25qualifiers.Count(), qpercentage,scoreless.Count(), srpercentage );
}
}
Console.WriteLine(Environment.NewLine + "Done");
}
}
}