Learning LINQ

Ref: https://www.youtube.com/playlist?list=PL6n9fhu94yhWi8K02Eqxp3Xyh_OmQ0Rp6

  1. Video 1
    1. Why Linq: Single Query language for XML, DB, Entity and Objects
    2. Linq Provider translates query to the data source friendly language
    3. with ADO.NET we write SQL queries as strings in code which is error prone. With LINQ, you
      1. Create Class for SQL server tables that u wanna query. Use VS – New Item – linq to sql class
      2. then use the datacontext to create query: from student in datacontext.student

Video 4

1. int? is nullable int

2. WE CAN EITHER WRITE LIKE THIS (extension method style..note these are extension methods in Enumerable class):  collection.where(Func<>) OR THIS (sql like syntax): find <property> in collection where <conditio> select <something>.

note that above returns IEnumerable

Video 7

when writing lambda, note that (a,b)=> a+b;

when applied to list {1,2,3,4} will do 1+2 first, then return 3, then add this 3 to next item, 3 …and so on…

When selecting, note that you can return anonymous type Eg.

var result = EmployeeList.Select(emp => new {name = emp.Name, gender= emp.Gender })

Here result will be of type iEnumerable of anonymous type…

Video 8

Select many flattens out hierarchy…so if you give it a collection/array of string having 2 strings, stringArray.SelectMany(s=>s) will return a IEnumerable<char> with 2nd string contents appended to 1st string contents

in SQL syntax thsi is: from s in StringArray from c in s select c

Mix extension method and SQL style:

(from s in StringArray from c in s select c).Distinct();

is valid

Also, you can choose to run a function on all s : stringArray.SelectMany(s=>s.Subjects, (student,sub)=> {new {stuName = student.Name, subject = sub}})

This is clearer in SQL Syntax:

from student in Student.GetAllSubjects()

from subject in student.Subjects

select {new {stuName = student.Name, subject = sub}

Video 10

OrderBy returns IOrderedEnumerable<T> but can take in IEnum too as IorderedEn inherits IEnum

Video 14

LINQ query is run when the result is needed, not where defined..deffered execution

But to execute it where its defined, use .ToList() or .Count()

 

last video watched: 15: https://www.youtube.com/watch?v=an_bpgQ7y9w&list=PL6n9fhu94yhWi8K02Eqxp3Xyh_OmQ0Rp6

c# reactive extensionBASICALLSDSDSDSDvar

http://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fteched%2f2012%2feu%2fDEV413.pptx

Basics

  1. Events can be treated like Collection. Both are stream of items of a particular type
  2. Every Collection needs to implement IEnumerable
  3. Rx is a layer on top of disparate event (generated by disparate sources like cloud, svc, hardware) that can be consolidated into single collection
  4. So basically our code is Observer subscribing to a Rx Observable (collection of events)
  5. Now whenever a new event occurs in the world, Obbserver’s callback is called..so this is non blocking async action…
  6. IObservable can raise Next () when next event occurs, or Error() or complete() like Pub Sub Model
  7. Rx vs Events:
    1. Events aren’t 1st class, so can’t pass them around, while IObservable<T> is Type
    2. have to be managed individually, while Observable has dispose to dispose off all event handlers
    3. Observable implements iEnumerable and so can be enumerated or written LYNQ query on..
  8. BASICALLY RX OBSERVABLE<T> IS COLLECTION OF EVENTS, AND AN ABSTRACTION LAYER OVER EVENTS TO MANAGE THEM TOGETHER
  9. rx can be used from rx-main nuget .it has 4 dlls
  10. tO CREATE OBSERVABLE FROM NORMAL C# EVENTS: var observable = Observable.FromEventPattern(EVENT);
  11. then say observable.subscribe()
  12. But to do lynq, say: var observable = from _ in Observable.FromEventPattern(textbox) select  textbox.text. Throttle()…ie you can use RX features on this iObservable stream..
  13. Now if another action needs to be performed on this stream, keep it ready:
    1. var result = from observalbe select …..
    2. Then subs to : result.subscribe(observable)

Visual Studio 2012 shortcuts

  1. shift + Enter: Terminate the current line and go to a new one
  2. solution explorer enhancements:
    1. Ctrl + Shift + F : search bar matched regEx
  3. Quick Launch
    1. @ in Quick Launch for additional features
    2. Type “present” to present
  4. Has expression builder when reg ex checkbox is selected
  5. Anywhere in VS or Office, Alt+ Down Arrow expands the dropdown
  6. When working on multiple projects in same solution, rt clk on project and say”open in new view to open it in new window “
  7. when viewing diff of files, u can change the view to inline view
  8. slution explorer also shows pending changes in it..its a filter on top of it…So u don;t need team explorer open for it

YouTube TV

This version of youtube works great on the bowser for watching videos…: youtube.com/tv

Shortuts:

s: Search

L : Seek Ahead

J: Seek Back

k: or Space Pause/Play

Down Arrow: Other uploads by same channel, watch hustory, what to watch, related videos

G: Go Home

Enter: Show Video Overlay with Actions

Esc: Back from current action

Backspace: Back from current video

Splunk Search Guide

Cheat Sheets

BEST

Search Reference: http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/SearchCheatsheet

DRILL DOWN

  1. In the search result, click on any keyword to add it to the search query with AND operator and clk on the same keyword again in the result and it’ll get removed from the query…its like toggle
  2. But Alt + Clk will add the keyword with NOT operator
  3. Splunk looks for Keywords in search fields so add *  to error to search for errors etc. keywords
  4. search is case insensitive wrt VALUE, but not wrt KEY
  5. Splunk normalizes the time from logs belonging to different zones to a common zone
  6. ” abc* tst” for phrase search
  7. Default Timeline chart in all searches at top of results can be used to drill down easily

REPORTS

In search results only, the fieds show up in LHS..

Clk on the one of interest and select “Top values by time” to get this added to query: | timechart count by <field>

When adding Time Picker to Dashboard, all panels must be inline searches,,, but report is not an inline search and so in panel props clone it to inline search

SAVE SEARCH

how to save searches in splunk?

http://docs.splunk.com/Documentation/Storm/Storm/User/Saveasearch

EVERY SEARCH can be saved as

1. Just a search string: Save as EVENT

2. Save as REPORT (which can be scheduled as well)

3. SAVE as DASHBOARD (which is a container of Reports and Events)

Create REPORT using PIVOT

Cllk Pivot on the top Menu