Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- udr.bytesin > 1000 && (udr.analysis.discrepency > 100000 || udr.analysis.discrepency_percent > 100) && udr.started_date > '2008-11-10 22:00:44' order by udr.analysis.discrepency DESC LIMIT 10
- class Udr { // formatted for space
- public int BytesIn { get; set; }
- public UdrAnalysis Analysis { get; set; }
- public DateTime StartedDate { get; set; }
- }
- class UdrAnalysis {
- public int Discrepency { get; set; }
- public int DiscrepencyPercent { get; set; }
- }
- static class Program {
- static void Main() {
- Udr[] data = new [] {
- new Udr { BytesIn = 50000, StartedDate = DateTime.Today,
- Analysis = new UdrAnalysis { Discrepency = 50000, DiscrepencyPercent = 130}},
- new Udr { BytesIn = 500, StartedDate = DateTime.Today,
- Analysis = new UdrAnalysis { Discrepency = 50000, DiscrepencyPercent = 130}}
- };
- DateTime when = DateTime.Parse("2008-11-10 22:00:44");
- var query = data.AsQueryable().Where(
- @"bytesin > 1000 && (analysis.discrepency > 100000
- || analysis.discrepencypercent > 100)
- && starteddate > @0",when)
- .OrderBy("analysis.discrepency DESC")
- .Take(10);
- foreach(var item in query) {
- Console.WriteLine(item.BytesIn);
- }
- }
- }
- static IEnumerable<Foo> ReadFoos(string path) {
- return from line in ReadLines(path)
- let parts = line.Split('|')
- select new Foo { Name = parts[0],
- Size = int.Parse(parts[1]) };
- }
- static IEnumerable<string> ReadLines(string path) {
- using (var reader = File.OpenText(path)) {
- string line;
- while ((line = reader.ReadLine()) != null) {
- yield return line;
- }
- }
- }
Add Comment
Please, Sign In to add comment