Tuesday, January 10, 2012
JQuery Notes 12Jan12
------------------
Point 1
------------------
<script>
//hide all divs on the page
jQuery('div').hide();
//update the text contained inside of all divs
jQuery('div').text('new content added here');
//add css stylesheet to all div tags
jQuery('div').addClass("updatedContent");
//show all divs on the page
jQuery('div').show();
//add css stylesheet to all input tags
jQuery('input').addClass("updatedContent");
//hide all input tags on the page
jQuery('input').hide();
// all inputs with css1 stylesheets
jQuery('input.css1').hide();
</script>
------------------
Point 2
------------------
jQuery methods - hide(), text(), addClass(), show()
------------------
Point 3
------------------
alert('Page contains ' + jQuery('a').length + ' <a> elements!');
jQuery('a').attr("href", "http://www.google.co.in");
$('a').attr("href", "http://www.google.com");
------------------
Point 4
------------------
<form>
<div>murali</div>
</form>
<form>
<div>murali 100</div>
</form>
<div>murali 200</div>
<script>
jQuery('div').text('new content added here - with out form tag');
jQuery('div',$('form')).text('new content added here - with form tag');
</script>
------------------
Point 5
------------------
<style type="text/css">
.external
{
}
</style>
<div class='external'>1000</div>
<div class='external'>1001</div>
<div>1002</div>
<div>1003</div>
<div class='external'>1004</div>
jQuery('div').filter(".external").text("Hello Maccha");
------------------
Point 6
------------------
$('div').css('font-size','24px');
$('div').css('color','Black');
$('div').css('font-family','Roman');
------------------
Point 7
------------------
<ul>
<li><a href="#">Google</a></li>
<li><a href="#">Yahoo</a></li>
<li><a href="#">Gmail</a></li>
<li><a href="#">Telugu People</a></li>
<li><a href="#">Andhra Vilas</a></li>
<li><a href="#">Great Andhra</a></li>
</ul>
$('li:eq(0)').find('a').attr("href", "http://www.google.co.in");
$('li:eq(0)').next().find('a').attr("href", "http://www.yahoomail.com");
$('li:eq(1)').next().text("sajfklasdj fklsjd fklsjd fklsdj jkl");
$('li:eq(2)').nextAll().find('a').attr("href", "http://www.telugu.greatandhra.com");
$('li:eq(2)').nextAll().find('a').text("Great Andhra");
------------------
Point 8
------------------
<div id="first">This is the first statement.</div>
<div id="second">This is the second statement.</div>
<div id="third">This is the third statement.</div>
<ul id="empno">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
$('a').filter('.css').remove();
$('a').remove('.css100');
$('#first').replaceWith('<p><b>Murali</b></p>');
$('ul#empno li').text('Employee Number : 1');
// adding multiple attributes
$('#company').attr({'class':'murali','title':'company information'}).text('Value Labs, Hyderabad');
// adding html text
$('#comp').html('<strong>Hello World</strong>');
------------------
Point 9
------------------
<a href="/category">Category</a>
<ul id="nav">
<li><a href="#anchor1">Anchor 1</a></li>
<li><a href="#anchor2">Anchor 2</a></li>
<li><span><a href="#anchor3">Anchor 3</a></span></li>
</ul>
$('#nav li').find('a').attr("href","http://www.google.com"); all a
$('#nav li a').attr("href","http://www.google.com"); all a
$('#nav li > a').attr("href","http://www.google.com"); only immediate a
------------------
Point 10
------------------
//$('h1 + h2').text('Murali'); // h2 follows h1. h2 is updated
//$('h2 + h1').text('Murali'); // h1 follows h2. h1 is updated
//$('h1').siblings('h2,h3,p').text('Murali');
$('li.selected').nextAll('li').css('background-color','red');
$('li.selected').prevAll('li').css('background-color','green');
$('li.selected').next('li').css('background-color','red');
$('li.selected').next().css('background-color','red');
------------------
Point 11
------------------
<table id="tblEmpDetails">
<thead><td>Emp Number</td><td>Name</td></thead>
<tr><td>Employee Number : 0</td><td>even - Murali Krishna V</td></tr>
<tr><td>Employee Number : 1</td><td>odd - Dasari Subrahmanyam</td></tr>
<tr><td>Employee Number : 2</td><td>even - Rakesh Mupparam</td></tr>
<tr><td>Employee Number : 3</td><td>odd - Suresh M</td></tr>
<tr><td>Employee Number : 4</td><td>even - Lakshman A</td></tr>
</table>
$('#tblEmpDetails tr:even').css('background-color','red');
$('#tblEmpDetails tr:odd').css('background-color','green');
<table id="Table1">
<thead><td>Emp Number</td><td>Name</td></thead>
<tr><td>Employee Number : 0</td><td>even - Murali Krishna V</td></tr>
</table>
$('tr:even').css('background-color','yellow');
$('tr:odd').css('background-color','cyan');
------------------
Point 12
------------------
<span>Hello Bob!</span>
// Select all SPANs with 'Bob' in:
jQuery('span:contains("Bob")');
jQuery('div:has(p a)');
------------------
Point 13
------------------
<div id="Menu">
<a href="#">Destinations</a><br />
<a href="#">Risk Assessments</a><br />
<a href="#">About Us</a><br />
<a href="#">Contact Us</a><br />
</div>
<script type="text/javascript">
$(function ()
{
$("div#Menu a").mouseover(function () { $(this).addClass("highlightRow"); })
.mouseout(function () { $(this).removeClass("highlightRow"); }
);
})
$("div#Menu a").click(function ()
{
alert( $(this).text() );
});
</script>
------------------
Point 14 - Chapter 3
------------------
Looping Concepts
<div id="Menu">
<a href="www.google.co.in">Destinations</a><br />
<a href="www.google.com">Risk Assessments</a><br />
<a href="www.yahoomail.com">About Us</a><br />
<a href="www.facebook.com">Contact Us</a><br />
</div>
var urls = [];
$("div#Menu a[href]").each(function(i) {
urls[i] = $(this).attr('href');
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
alert( urls.join(","));
WRONG CODE
--------------
$("div#Menu a[href]")(function()
{
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
------------------
Point 15
------------------
<ul id="names">
<li>Ralph</li>
<li>Hope</li>
<li>Brandon</li>
<li>Jordan</li>
<li>Ralphie</li>
</ul>
$("ul > li").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li").css("border-bottom", "1px solid red").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li:first").css("border-top", "5px solid green");
$("ul > li:last").css("border-top", "5px solid green");
$("ul > li:eq(5)").css("border-top", "5px solid green");
(function($){
$(document).ready(function() {
$("ul > li").each(function(i) {
if (i % 2 == 1)
{
$(this).css("border", "2px solid red")
}
else
{
$(this).css("border", "3px solid green")
}
});
});
})(jQuery);
------------------
Point 16
------------------
<h2>Value Labs - Employees</h2>
<div>
<ul id="names">
<li>Murali</li>
<li>Krishna</li>
<li>Rakesh</li>
<li>Subbu</li>
<li>Lakshman</li>
<li>Vara</li>
<li>Shiva</li>
<li>Suresh</li>
<li>Mitesh</li>
<li>Vishnu</li>
</ul>
</div>
(function($)
{
$(document).ready(function()
{
var lis = $("ul li").get().reverse();
//$("ul").empty();
$.each(lis, function(i)
{
$(this).css("color", "white");
});
$("ul").append("<li>+++++++++++++++++++++++++</li>");
$.each(lis, function(i)
{
$("ul").append("<li class='reverseCss'>" + lis[i].innerHTML + "</li>");
});
$("li").filter(".reverseCss").css("color", "gold");
});
})(jQuery);
$("h2").addClass("Emp");
$("div").addClass("divEmp");
------------------
Point 17
------------------
(function($)
{
$(document).ready(function()
{
$("div").click(function()
{
alert("You clicked on div with an index of " + $("div").index(this) );
alert("You clicked on div with an index of " + $(this).text() );
});
});
})(jQuery);
------------------
Point 18
------------------
<div>
<br />
<p>Murali Krishna - p element</p> <br />
<p>Murali - p element</p> <br />
<p>Krishna - p element</p> <br />
<input type="text" id="txt1" /> <br />
<a href="#">Google 1</a><br />
<a href="#">Google 2</a><br />
<a href="#">Google 3</a><br />
<b>India</b><br />
<strong>India</strong><br />
<br />
</div>
<div>
<p>Raju</p>
</div>
<div>
<p>Rakesh + Raju</p>
</div>
$("div").each(function(i)
{
if ($('div').index(this) % 2 == 0)
{
$(this).text('I am ' + $(this).text() );
}
else
{
$(this).text('You Are : ' + $(this).text() );
}
});
------------------
Point 19
------------------
<h1>jQuery Cookbook Authors</h1>
<ol>
<li>John Resig</li>
<li>Cody Lindley</li>
<li>James Padolsey</li>
<li>Ralph Whitbeck</li>
</ol>
(function($)
{
$(document).ready(function()
{
$.each( $("li") , function(i)
{
alert( $(this).text() );
});
});
})(jQuery);
------------------
Point 20
------------------
Note:- jQuery utility method $.map(), which will transform an existing array into another array of items.
(function($)
{
$(document).ready(function()
{
var arr = $.map([100,200,300], function(item, index)
{
alert( item + 1 );
});
});
})(jQuery);
------------------
Point 21
------------------
(function($)
{
$(document).ready(function()
{
var arr = $.map($("li"), function(item, index)
{
while (index < 3)
{
return $(item).html();
}
return null;
});
$(document.body).append("<span>The first three authors are: " + arr.join(", ") + "</span>");
});
})(jQuery);
------------------
Point 22
------------------
<ul>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
</ul>
$("li").slice(1,2).wrap("<b><i></i></b>").css('color','red').css('background-color','gold').css('width','200px');
------------------
Point 23 - Chapter 4
------------------
<a href="#">Broken Links</a><br />
<a href="http://www.google.co.in">www.google.co.in</a><br />
<a href="http://abc.com">abc</a><br />
<a href="#">Broken Links</a><br />
<a href="http://xyz.com">xyz</a><br />
<a href="#">Broken Links</a><br />
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 24
------------------
<a href="#">Broken Links</a><br />
<a href="h:/www.google.co.in">www.google.co.in</a><br />
<a href="http://abc.com">abc</a><br />
<a href="#">Broken Links</a><br />
<a href="hp://xyz.com">xyz</a><br />
<a href="#">Broken Links</a><br />
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
else
{
var myVariable = $(this).attr('href');
if(myVariable == 'http://abc.com')
{
}
else
{
$(this).attr('href',"http://andhravilas.com");
$(this).text('Andhra Vilas');
}
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 25
------------------
<h1>Months</h1>
<ol id="months"></ol>
<br />
<h1>Weekdays</h1>
<ol id="weekday"></ol>
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
$.each(months, function(index, value)
{
$('#months').append('<li>' + value + '</li>');
});
var days = { Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3,
Thursday: 4, Friday: 5, Saturday: 6 };
$.each(days, function(key, value)
{
$('#weekday').append("<li>" + key + ' (' + value + ')</li>');
});
});
})(jQuery);
------------------
Point 26
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
var months = $.grep(months, function(value, i)
{
return ( value.indexOf('A') == 0 );
});
$('#months').html( '<li>' + months.join('</li><li>') + '</li>' );
});
})(jQuery);
it can be written as below as well using map utility
var monthsNew = $.map(months, function(value, i)
{
return ( value.indexOf('J') == 0 ? value : null );
});
$('#months').html( '<li>' + monthsNew.join('</li><li>') + '</li>' );
------------------
Point 27
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
months = $.map(months, function(value, i)
{
var monthname = value.substr(0,3);
switch(monthname)
{
case "Jan" :
case "Mar" :
case "May" :
case "Jul" :
case "Aug" :
case "Oct" :
case "Dec" :
return value + " - 31";
break;
case "Feb" :
return value + " - 28";
break;
case "Apr" :
case "Jun" :
case "Sep" :
case "Nov" :
return value + " - 30";
break;
default: return "";
}
});
$('#months').html( '<li>' + months.join('</li><li>') + '</li>' );
});
})(jQuery);
------------------
Point 28
------------------
Merging two arrays sets
$('#months').html( '<li>' + $.merge(months,monthsNew).join('</li><li>') + '</li>' );
------------------
Point 29
------------------
------------------
Point 30
------------------
------------------
Point 31
------------------
------------------
Point 32
------------------
Point 1
------------------
<script>
//hide all divs on the page
jQuery('div').hide();
//update the text contained inside of all divs
jQuery('div').text('new content added here');
//add css stylesheet to all div tags
jQuery('div').addClass("updatedContent");
//show all divs on the page
jQuery('div').show();
//add css stylesheet to all input tags
jQuery('input').addClass("updatedContent");
//hide all input tags on the page
jQuery('input').hide();
// all inputs with css1 stylesheets
jQuery('input.css1').hide();
</script>
------------------
Point 2
------------------
jQuery methods - hide(), text(), addClass(), show()
------------------
Point 3
------------------
alert('Page contains ' + jQuery('a').length + ' <a> elements!');
jQuery('a').attr("href", "http://www.google.co.in");
$('a').attr("href", "http://www.google.com");
------------------
Point 4
------------------
<form>
<div>murali</div>
</form>
<form>
<div>murali 100</div>
</form>
<div>murali 200</div>
<script>
jQuery('div').text('new content added here - with out form tag');
jQuery('div',$('form')).text('new content added here - with form tag');
</script>
------------------
Point 5
------------------
<style type="text/css">
.external
{
}
</style>
<div class='external'>1000</div>
<div class='external'>1001</div>
<div>1002</div>
<div>1003</div>
<div class='external'>1004</div>
jQuery('div').filter(".external").text("Hello Maccha");
------------------
Point 6
------------------
$('div').css('font-size','24px');
$('div').css('color','Black');
$('div').css('font-family','Roman');
------------------
Point 7
------------------
<ul>
<li><a href="#">Google</a></li>
<li><a href="#">Yahoo</a></li>
<li><a href="#">Gmail</a></li>
<li><a href="#">Telugu People</a></li>
<li><a href="#">Andhra Vilas</a></li>
<li><a href="#">Great Andhra</a></li>
</ul>
$('li:eq(0)').find('a').attr("href", "http://www.google.co.in");
$('li:eq(0)').next().find('a').attr("href", "http://www.yahoomail.com");
$('li:eq(1)').next().text("sajfklasdj fklsjd fklsjd fklsdj jkl");
$('li:eq(2)').nextAll().find('a').attr("href", "http://www.telugu.greatandhra.com");
$('li:eq(2)').nextAll().find('a').text("Great Andhra");
------------------
Point 8
------------------
<div id="first">This is the first statement.</div>
<div id="second">This is the second statement.</div>
<div id="third">This is the third statement.</div>
<ul id="empno">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
$('a').filter('.css').remove();
$('a').remove('.css100');
$('#first').replaceWith('<p><b>Murali</b></p>');
$('ul#empno li').text('Employee Number : 1');
// adding multiple attributes
$('#company').attr({'class':'murali','title':'company information'}).text('Value Labs, Hyderabad');
// adding html text
$('#comp').html('<strong>Hello World</strong>');
------------------
Point 9
------------------
<a href="/category">Category</a>
<ul id="nav">
<li><a href="#anchor1">Anchor 1</a></li>
<li><a href="#anchor2">Anchor 2</a></li>
<li><span><a href="#anchor3">Anchor 3</a></span></li>
</ul>
$('#nav li').find('a').attr("href","http://www.google.com"); all a
$('#nav li a').attr("href","http://www.google.com"); all a
$('#nav li > a').attr("href","http://www.google.com"); only immediate a
------------------
Point 10
------------------
//$('h1 + h2').text('Murali'); // h2 follows h1. h2 is updated
//$('h2 + h1').text('Murali'); // h1 follows h2. h1 is updated
//$('h1').siblings('h2,h3,p').text('Murali');
$('li.selected').nextAll('li').css('background-color','red');
$('li.selected').prevAll('li').css('background-color','green');
$('li.selected').next('li').css('background-color','red');
$('li.selected').next().css('background-color','red');
------------------
Point 11
------------------
<table id="tblEmpDetails">
<thead><td>Emp Number</td><td>Name</td></thead>
<tr><td>Employee Number : 0</td><td>even - Murali Krishna V</td></tr>
<tr><td>Employee Number : 1</td><td>odd - Dasari Subrahmanyam</td></tr>
<tr><td>Employee Number : 2</td><td>even - Rakesh Mupparam</td></tr>
<tr><td>Employee Number : 3</td><td>odd - Suresh M</td></tr>
<tr><td>Employee Number : 4</td><td>even - Lakshman A</td></tr>
</table>
$('#tblEmpDetails tr:even').css('background-color','red');
$('#tblEmpDetails tr:odd').css('background-color','green');
<table id="Table1">
<thead><td>Emp Number</td><td>Name</td></thead>
<tr><td>Employee Number : 0</td><td>even - Murali Krishna V</td></tr>
</table>
$('tr:even').css('background-color','yellow');
$('tr:odd').css('background-color','cyan');
------------------
Point 12
------------------
<span>Hello Bob!</span>
// Select all SPANs with 'Bob' in:
jQuery('span:contains("Bob")');
jQuery('div:has(p a)');
------------------
Point 13
------------------
<div id="Menu">
<a href="#">Destinations</a><br />
<a href="#">Risk Assessments</a><br />
<a href="#">About Us</a><br />
<a href="#">Contact Us</a><br />
</div>
<script type="text/javascript">
$(function ()
{
$("div#Menu a").mouseover(function () { $(this).addClass("highlightRow"); })
.mouseout(function () { $(this).removeClass("highlightRow"); }
);
})
$("div#Menu a").click(function ()
{
alert( $(this).text() );
});
</script>
------------------
Point 14 - Chapter 3
------------------
Looping Concepts
<div id="Menu">
<a href="www.google.co.in">Destinations</a><br />
<a href="www.google.com">Risk Assessments</a><br />
<a href="www.yahoomail.com">About Us</a><br />
<a href="www.facebook.com">Contact Us</a><br />
</div>
var urls = [];
$("div#Menu a[href]").each(function(i) {
urls[i] = $(this).attr('href');
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
alert( urls.join(","));
WRONG CODE
--------------
$("div#Menu a[href]")(function()
{
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
------------------
Point 15
------------------
<ul id="names">
<li>Ralph</li>
<li>Hope</li>
<li>Brandon</li>
<li>Jordan</li>
<li>Ralphie</li>
</ul>
$("ul > li").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li").css("border-bottom", "1px solid red").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li:first").css("border-top", "5px solid green");
$("ul > li:last").css("border-top", "5px solid green");
$("ul > li:eq(5)").css("border-top", "5px solid green");
(function($){
$(document).ready(function() {
$("ul > li").each(function(i) {
if (i % 2 == 1)
{
$(this).css("border", "2px solid red")
}
else
{
$(this).css("border", "3px solid green")
}
});
});
})(jQuery);
------------------
Point 16
------------------
<h2>Value Labs - Employees</h2>
<div>
<ul id="names">
<li>Murali</li>
<li>Krishna</li>
<li>Rakesh</li>
<li>Subbu</li>
<li>Lakshman</li>
<li>Vara</li>
<li>Shiva</li>
<li>Suresh</li>
<li>Mitesh</li>
<li>Vishnu</li>
</ul>
</div>
(function($)
{
$(document).ready(function()
{
var lis = $("ul li").get().reverse();
//$("ul").empty();
$.each(lis, function(i)
{
$(this).css("color", "white");
});
$("ul").append("<li>+++++++++++++++++++++++++</li>");
$.each(lis, function(i)
{
$("ul").append("<li class='reverseCss'>" + lis[i].innerHTML + "</li>");
});
$("li").filter(".reverseCss").css("color", "gold");
});
})(jQuery);
$("h2").addClass("Emp");
$("div").addClass("divEmp");
------------------
Point 17
------------------
(function($)
{
$(document).ready(function()
{
$("div").click(function()
{
alert("You clicked on div with an index of " + $("div").index(this) );
alert("You clicked on div with an index of " + $(this).text() );
});
});
})(jQuery);
------------------
Point 18
------------------
<div>
<br />
<p>Murali Krishna - p element</p> <br />
<p>Murali - p element</p> <br />
<p>Krishna - p element</p> <br />
<input type="text" id="txt1" /> <br />
<a href="#">Google 1</a><br />
<a href="#">Google 2</a><br />
<a href="#">Google 3</a><br />
<b>India</b><br />
<strong>India</strong><br />
<br />
</div>
<div>
<p>Raju</p>
</div>
<div>
<p>Rakesh + Raju</p>
</div>
$("div").each(function(i)
{
if ($('div').index(this) % 2 == 0)
{
$(this).text('I am ' + $(this).text() );
}
else
{
$(this).text('You Are : ' + $(this).text() );
}
});
------------------
Point 19
------------------
<h1>jQuery Cookbook Authors</h1>
<ol>
<li>John Resig</li>
<li>Cody Lindley</li>
<li>James Padolsey</li>
<li>Ralph Whitbeck</li>
</ol>
(function($)
{
$(document).ready(function()
{
$.each( $("li") , function(i)
{
alert( $(this).text() );
});
});
})(jQuery);
------------------
Point 20
------------------
Note:- jQuery utility method $.map(), which will transform an existing array into another array of items.
(function($)
{
$(document).ready(function()
{
var arr = $.map([100,200,300], function(item, index)
{
alert( item + 1 );
});
});
})(jQuery);
------------------
Point 21
------------------
(function($)
{
$(document).ready(function()
{
var arr = $.map($("li"), function(item, index)
{
while (index < 3)
{
return $(item).html();
}
return null;
});
$(document.body).append("<span>The first three authors are: " + arr.join(", ") + "</span>");
});
})(jQuery);
------------------
Point 22
------------------
<ul>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
<li>fskdjf</li>
</ul>
$("li").slice(1,2).wrap("<b><i></i></b>").css('color','red').css('background-color','gold').css('width','200px');
------------------
Point 23 - Chapter 4
------------------
<a href="#">Broken Links</a><br />
<a href="http://www.google.co.in">www.google.co.in</a><br />
<a href="http://abc.com">abc</a><br />
<a href="#">Broken Links</a><br />
<a href="http://xyz.com">xyz</a><br />
<a href="#">Broken Links</a><br />
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 24
------------------
<a href="#">Broken Links</a><br />
<a href="h:/www.google.co.in">www.google.co.in</a><br />
<a href="http://abc.com">abc</a><br />
<a href="#">Broken Links</a><br />
<a href="hp://xyz.com">xyz</a><br />
<a href="#">Broken Links</a><br />
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
else
{
var myVariable = $(this).attr('href');
if(myVariable == 'http://abc.com')
{
}
else
{
$(this).attr('href',"http://andhravilas.com");
$(this).text('Andhra Vilas');
}
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 25
------------------
<h1>Months</h1>
<ol id="months"></ol>
<br />
<h1>Weekdays</h1>
<ol id="weekday"></ol>
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
$.each(months, function(index, value)
{
$('#months').append('<li>' + value + '</li>');
});
var days = { Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3,
Thursday: 4, Friday: 5, Saturday: 6 };
$.each(days, function(key, value)
{
$('#weekday').append("<li>" + key + ' (' + value + ')</li>');
});
});
})(jQuery);
------------------
Point 26
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
var months = $.grep(months, function(value, i)
{
return ( value.indexOf('A') == 0 );
});
$('#months').html( '<li>' + months.join('</li><li>') + '</li>' );
});
})(jQuery);
it can be written as below as well using map utility
var monthsNew = $.map(months, function(value, i)
{
return ( value.indexOf('J') == 0 ? value : null );
});
$('#months').html( '<li>' + monthsNew.join('</li><li>') + '</li>' );
------------------
Point 27
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
months = $.map(months, function(value, i)
{
var monthname = value.substr(0,3);
switch(monthname)
{
case "Jan" :
case "Mar" :
case "May" :
case "Jul" :
case "Aug" :
case "Oct" :
case "Dec" :
return value + " - 31";
break;
case "Feb" :
return value + " - 28";
break;
case "Apr" :
case "Jun" :
case "Sep" :
case "Nov" :
return value + " - 30";
break;
default: return "";
}
});
$('#months').html( '<li>' + months.join('</li><li>') + '</li>' );
});
})(jQuery);
------------------
Point 28
------------------
Merging two arrays sets
$('#months').html( '<li>' + $.merge(months,monthsNew).join('</li><li>') + '</li>' );
------------------
Point 29
------------------
------------------
Point 30
------------------
------------------
Point 31
------------------
------------------
Point 32
------------------
JQuery Notes 10Jan2012
------------------
Point 1
------------------
------------------
Point 2
------------------
jQuery methods - hide(), text(), addClass(), show()
------------------
Point 3
------------------
alert('Page contains ' + jQuery('a').length + ' elements!');
jQuery('a').attr("href", "http://www.google.co.in");
$('a').attr("href", "http://www.google.com");
------------------
Point 4
------------------
------------------
Point 5
------------------
jQuery('div').filter(".external").text("Hello Maccha");
------------------
Point 6
------------------
$('div').css('font-size','24px');
$('div').css('color','Black');
$('div').css('font-family','Roman');
------------------
Point 7
------------------
$('li:eq(0)').find('a').attr("href", "http://www.google.co.in");
$('li:eq(0)').next().find('a').attr("href", "http://www.yahoomail.com");
$('li:eq(1)').next().text("sajfklasdj fklsjd fklsjd fklsdj jkl");
$('li:eq(2)').nextAll().find('a').attr("href", "http://www.telugu.greatandhra.com");
$('li:eq(2)').nextAll().find('a').text("Great Andhra");
------------------
Point 8
------------------
$('a').filter('.css').remove();
$('a').remove('.css100');
$('#first').replaceWith('
$('ul#empno li').text('Employee Number : 1');
// adding multiple attributes
$('#company').attr({'class':'murali','title':'company information'}).text('Value Labs, Hyderabad');
// adding html text
$('#comp').html('Hello World');
------------------
Point 9
------------------
Category
$('#nav li').find('a').attr("href","http://www.google.com"); all a
$('#nav li a').attr("href","http://www.google.com"); all a
$('#nav li > a').attr("href","http://www.google.com"); only immediate a
------------------
Point 10
------------------
//$('h1 + h2').text('Murali'); // h2 follows h1. h2 is updated
//$('h2 + h1').text('Murali'); // h1 follows h2. h1 is updated
//$('h1').siblings('h2,h3,p').text('Murali');
$('li.selected').nextAll('li').css('background-color','red');
$('li.selected').prevAll('li').css('background-color','green');
$('li.selected').next('li').css('background-color','red');
$('li.selected').next().css('background-color','red');
------------------
Point 11
------------------
$('#tblEmpDetails tr:even').css('background-color','red');
$('#tblEmpDetails tr:odd').css('background-color','green');
$('tr:even').css('background-color','yellow');
$('tr:odd').css('background-color','cyan');
------------------
Point 12
------------------
Hello Bob!
// Select all SPANs with 'Bob' in:
jQuery('span:contains("Bob")');
jQuery('div:has(p a)');
------------------
Point 13
------------------
------------------
Point 14 - Chapter 3
------------------
Looping Concepts
var urls = [];
$("div#Menu a[href]").each(function(i) {
urls[i] = $(this).attr('href');
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
alert( urls.join(","));
WRONG CODE
--------------
$("div#Menu a[href]")(function()
{
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
------------------
Point 15
------------------
$("ul > li").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li").css("border-bottom", "1px solid red").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li:first").css("border-top", "5px solid green");
$("ul > li:last").css("border-top", "5px solid green");
$("ul > li:eq(5)").css("border-top", "5px solid green");
(function($){
$(document).ready(function() {
$("ul > li").each(function(i) {
if (i % 2 == 1)
{
$(this).css("border", "2px solid red")
}
else
{
$(this).css("border", "3px solid green")
}
});
});
})(jQuery);
------------------
Point 16
------------------
(function($)
{
$(document).ready(function()
{
var lis = $("ul li").get().reverse();
//$("ul").empty();
$.each(lis, function(i)
{
$(this).css("color", "white");
});
$("ul").append("+++++++++++++++++++++++++ ");
$.each(lis, function(i)
{
$("ul").append("" + lis[i].innerHTML + " ");
});
$("li").filter(".reverseCss").css("color", "gold");
});
})(jQuery);
$("h2").addClass("Emp");
$("div").addClass("divEmp");
------------------
Point 17
------------------
(function($)
{
$(document).ready(function()
{
$("div").click(function()
{
alert("You clicked on div with an index of " + $("div").index(this) );
alert("You clicked on div with an index of " + $(this).text() );
});
});
})(jQuery);
------------------
Point 18
------------------
Google 1
Google 2
Google 3
India
India
$("div").each(function(i)
{
if ($('div').index(this) % 2 == 0)
{
$(this).text('I am ' + $(this).text() );
}
else
{
$(this).text('You Are : ' + $(this).text() );
}
});
------------------
Point 19
------------------
(function($)
{
$(document).ready(function()
{
$.each( $("li") , function(i)
{
alert( $(this).text() );
});
});
})(jQuery);
------------------
Point 20
------------------
Note:- jQuery utility method $.map(), which will transform an existing array into another array of items.
(function($)
{
$(document).ready(function()
{
var arr = $.map([100,200,300], function(item, index)
{
alert( item + 1 );
});
});
})(jQuery);
------------------
Point 21
------------------
(function($)
{
$(document).ready(function()
{
var arr = $.map($("li"), function(item, index)
{
while (index < 3)
{
return $(item).html();
}
return null;
});
$(document.body).append("The first three authors are: " + arr.join(", ") + "");
});
})(jQuery);
------------------
Point 22
------------------
$("li").slice(1,2).wrap("").css('color','red').css('background-color','gold').css('width','200px');
------------------
Point 23 - Chapter 4
------------------
Broken Links
www.google.co.in
abc
Broken Links
xyz
Broken Links
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 24
------------------
Broken Links
www.google.co.in
abc
Broken Links
xyz
Broken Links
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
else
{
var myVariable = $(this).attr('href');
if(myVariable == 'http://abc.com')
{
}
else
{
$(this).attr('href',"http://andhravilas.com");
$(this).text('Andhra Vilas');
}
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 25
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
$.each(months, function(index, value)
{
$('#months').append('' + value + ' ');
});
var days = { Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3,
Thursday: 4, Friday: 5, Saturday: 6 };
$.each(days, function(key, value)
{
$('#weekday').append("" + key + ' (' + value + ') ');
});
});
})(jQuery);
------------------
Point 26
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
var months = $.grep(months, function(value, i)
{
return ( value.indexOf('A') == 0 );
});
$('#months').html( '' + months.join(' ') + ' ' );
});
})(jQuery);
it can be written as below as well using map utility
var monthsNew = $.map(months, function(value, i)
{
return ( value.indexOf('J') == 0 ? value : null );
});
$('#months').html( '' + monthsNew.join(' ') + ' ' );
------------------
Point 27
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
months = $.map(months, function(value, i)
{
var monthname = value.substr(0,3);
switch(monthname)
{
case "Jan" :
case "Mar" :
case "May" :
case "Jul" :
case "Aug" :
case "Oct" :
case "Dec" :
return value + " - 31";
break;
case "Feb" :
return value + " - 28";
break;
case "Apr" :
case "Jun" :
case "Sep" :
case "Nov" :
return value + " - 30";
break;
default: return "";
}
});
$('#months').html( '' + months.join(' ') + ' ' );
});
})(jQuery);
------------------
Point 28
------------------
Merging two arrays sets
$('#months').html( '' + $.merge(months,monthsNew).join(' ') + ' ' );
------------------
Point 29
------------------
------------------
Point 30
------------------
------------------
Point 31
------------------
------------------
Point 32
------------------
Point 1
------------------
------------------
Point 2
------------------
jQuery methods - hide(), text(), addClass(), show()
------------------
Point 3
------------------
alert('Page contains ' + jQuery('a').length + ' elements!');
jQuery('a').attr("href", "http://www.google.co.in");
$('a').attr("href", "http://www.google.com");
------------------
Point 4
------------------
murali 200
------------------
Point 5
------------------
1000
1001
1002
1003
1004
jQuery('div').filter(".external").text("Hello Maccha");
------------------
Point 6
------------------
$('div').css('font-size','24px');
$('div').css('color','Black');
$('div').css('font-family','Roman');
------------------
Point 7
------------------
$('li:eq(0)').find('a').attr("href", "http://www.google.co.in");
$('li:eq(0)').next().find('a').attr("href", "http://www.yahoomail.com");
$('li:eq(1)').next().text("sajfklasdj fklsjd fklsjd fklsdj jkl");
$('li:eq(2)').nextAll().find('a').attr("href", "http://www.telugu.greatandhra.com");
$('li:eq(2)').nextAll().find('a').text("Great Andhra");
------------------
Point 8
------------------
This is the first statement.
This is the second statement.
This is the third statement.
- 1
- 2
- 3
$('a').filter('.css').remove();
$('a').remove('.css100');
$('#first').replaceWith('
Murali
');$('ul#empno li').text('Employee Number : 1');
// adding multiple attributes
$('#company').attr({'class':'murali','title':'company information'}).text('Value Labs, Hyderabad');
// adding html text
$('#comp').html('Hello World');
------------------
Point 9
------------------
Category
$('#nav li').find('a').attr("href","http://www.google.com"); all a
$('#nav li a').attr("href","http://www.google.com"); all a
$('#nav li > a').attr("href","http://www.google.com"); only immediate a
------------------
Point 10
------------------
//$('h1 + h2').text('Murali'); // h2 follows h1. h2 is updated
//$('h2 + h1').text('Murali'); // h1 follows h2. h1 is updated
//$('h1').siblings('h2,h3,p').text('Murali');
$('li.selected').nextAll('li').css('background-color','red');
$('li.selected').prevAll('li').css('background-color','green');
$('li.selected').next('li').css('background-color','red');
$('li.selected').next().css('background-color','red');
------------------
Point 11
------------------
| Emp Number | Name |
| Employee Number : 0 | even - Murali Krishna V |
| Employee Number : 1 | odd - Dasari Subrahmanyam |
| Employee Number : 2 | even - Rakesh Mupparam |
| Employee Number : 3 | odd - Suresh M |
| Employee Number : 4 | even - Lakshman A |
$('#tblEmpDetails tr:even').css('background-color','red');
$('#tblEmpDetails tr:odd').css('background-color','green');
| Emp Number | Name |
| Employee Number : 0 | even - Murali Krishna V |
$('tr:even').css('background-color','yellow');
$('tr:odd').css('background-color','cyan');
------------------
Point 12
------------------
Hello Bob!
// Select all SPANs with 'Bob' in:
jQuery('span:contains("Bob")');
jQuery('div:has(p a)');
------------------
Point 13
------------------
------------------
Point 14 - Chapter 3
------------------
Looping Concepts
var urls = [];
$("div#Menu a[href]").each(function(i) {
urls[i] = $(this).attr('href');
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
alert( urls.join(","));
WRONG CODE
--------------
$("div#Menu a[href]")(function()
{
$(this).attr("href","http://www.murali.com").text("www.murali.com");
});
------------------
Point 15
------------------
- Ralph
- Hope
- Brandon
- Jordan
- Ralphie
$("ul > li").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li").css("border-bottom", "1px solid red").eq(7).css("border-bottom", "1px solid #000000");
$("ul > li:first").css("border-top", "5px solid green");
$("ul > li:last").css("border-top", "5px solid green");
$("ul > li:eq(5)").css("border-top", "5px solid green");
(function($){
$(document).ready(function() {
$("ul > li").each(function(i) {
if (i % 2 == 1)
{
$(this).css("border", "2px solid red")
}
else
{
$(this).css("border", "3px solid green")
}
});
});
})(jQuery);
------------------
Point 16
------------------
Value Labs - Employees
- Murali
- Krishna
- Rakesh
- Subbu
- Lakshman
- Vara
- Shiva
- Suresh
- Mitesh
- Vishnu
(function($)
{
$(document).ready(function()
{
var lis = $("ul li").get().reverse();
//$("ul").empty();
$.each(lis, function(i)
{
$(this).css("color", "white");
});
$("ul").append("
$.each(lis, function(i)
{
$("ul").append("
});
$("li").filter(".reverseCss").css("color", "gold");
});
})(jQuery);
$("h2").addClass("Emp");
$("div").addClass("divEmp");
------------------
Point 17
------------------
(function($)
{
$(document).ready(function()
{
$("div").click(function()
{
alert("You clicked on div with an index of " + $("div").index(this) );
alert("You clicked on div with an index of " + $(this).text() );
});
});
})(jQuery);
------------------
Point 18
------------------
Murali Krishna - p element
Murali - p element
Krishna - p element
Google 1
Google 2
Google 3
India
India
Raju
Rakesh + Raju
$("div").each(function(i)
{
if ($('div').index(this) % 2 == 0)
{
$(this).text('I am ' + $(this).text() );
}
else
{
$(this).text('You Are : ' + $(this).text() );
}
});
------------------
Point 19
------------------
jQuery Cookbook Authors
- John Resig
- Cody Lindley
- James Padolsey
- Ralph Whitbeck
(function($)
{
$(document).ready(function()
{
$.each( $("li") , function(i)
{
alert( $(this).text() );
});
});
})(jQuery);
------------------
Point 20
------------------
Note:- jQuery utility method $.map(), which will transform an existing array into another array of items.
(function($)
{
$(document).ready(function()
{
var arr = $.map([100,200,300], function(item, index)
{
alert( item + 1 );
});
});
})(jQuery);
------------------
Point 21
------------------
(function($)
{
$(document).ready(function()
{
var arr = $.map($("li"), function(item, index)
{
while (index < 3)
{
return $(item).html();
}
return null;
});
$(document.body).append("The first three authors are: " + arr.join(", ") + "");
});
})(jQuery);
------------------
Point 22
------------------
- fskdjf
- fskdjf
- fskdjf
- fskdjf
- fskdjf
- fskdjf
$("li").slice(1,2).wrap("").css('color','red').css('background-color','gold').css('width','200px');
------------------
Point 23 - Chapter 4
------------------
Broken Links
www.google.co.in
abc
Broken Links
xyz
Broken Links
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 24
------------------
Broken Links
www.google.co.in
abc
Broken Links
xyz
Broken Links
(function($)
{
$(document).ready(function()
{
$('a').filter(function()
{
if ( $(this).attr('href') == "#" )
{
$(this).attr('href',"http://telugu.greatandhra.com");
$(this).text('Great Andhra');
}
else
{
var myVariable = $(this).attr('href');
if(myVariable == 'http://abc.com')
{
}
else
{
$(this).attr('href',"http://andhravilas.com");
$(this).text('Andhra Vilas');
}
}
}).click(function() {
});
});
})(jQuery);
------------------
Point 25
------------------
Months
Weekdays
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
$.each(months, function(index, value)
{
$('#months').append('
});
var days = { Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3,
Thursday: 4, Friday: 5, Saturday: 6 };
$.each(days, function(key, value)
{
$('#weekday').append("
});
});
})(jQuery);
------------------
Point 26
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
var months = $.grep(months, function(value, i)
{
return ( value.indexOf('A') == 0 );
});
$('#months').html( '
});
})(jQuery);
it can be written as below as well using map utility
var monthsNew = $.map(months, function(value, i)
{
return ( value.indexOf('J') == 0 ? value : null );
});
$('#months').html( '
------------------
Point 27
------------------
(function($)
{
$(document).ready(function()
{
var months = [ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'];
months = $.map(months, function(value, i)
{
var monthname = value.substr(0,3);
switch(monthname)
{
case "Jan" :
case "Mar" :
case "May" :
case "Jul" :
case "Aug" :
case "Oct" :
case "Dec" :
return value + " - 31";
break;
case "Feb" :
return value + " - 28";
break;
case "Apr" :
case "Jun" :
case "Sep" :
case "Nov" :
return value + " - 30";
break;
default: return "";
}
});
$('#months').html( '
});
})(jQuery);
------------------
Point 28
------------------
Merging two arrays sets
$('#months').html( '
------------------
Point 29
------------------
------------------
Point 30
------------------
------------------
Point 31
------------------
------------------
Point 32
------------------
Tuesday, February 22, 2011
Working with Ajax toolkit
1. find AjaxControlToolkit.dll. and place it in your bin folder
2. add the following tag in aspx page
< % @ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" % >
3. try the following code
< asp: Panel ID="pnlShowXMLElements" runat="server" CssClass="XMLPopupModalBG" ScrollBars="Vertical" >
< table >
< tr >
< td align="center" style="width:600px">
< /td>
< /tr>
< tr>
< td>
< /td>
< /tr>
< tr id="tr1">
< td>
AutoGenerateDataBindings="true"
OnSelectedNodeChanged="treeSource_SelectionChanged" />
< /td>
< /tr>
< /table>
< /asp:Panel>
< ajax: ModalPopupExtender ID="modalpopup" runat="server" DropShadow="true"
CancelControlID="btnCancelPopup"
TargetControlID="btnOpenTreeView" PopupControlID="pnlShowXMLElements" / >
4. create css class files
5. debug and test
2. add the following tag in aspx page
< % @ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" % >
3. try the following code
< asp: Panel ID="pnlShowXMLElements" runat="server" CssClass="XMLPopupModalBG" ScrollBars="Vertical" >
< table >
< tr >
< td align="center" style="width:600px">
< /td>
< /tr>
< tr>
< td>
< /td>
< /tr>
< tr id="tr1">
< td>
OnSelectedNodeChanged="treeSource_SelectionChanged" />
< /td>
< /tr>
< /table>
< /asp:Panel>
< ajax: ModalPopupExtender ID="modalpopup" runat="server" DropShadow="true"
CancelControlID="btnCancelPopup"
TargetControlID="btnOpenTreeView" PopupControlID="pnlShowXMLElements" / >
4. create css class files
5. debug and test
Friday, October 8, 2010
Friday, October 1, 2010
LINQ Coding
LINQ coding
-------------------------------
//from c in MurSapeliCovers
//join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
//{ cid = o.CustId, coid=o.CoverId} into g
//from o in g.DefaultIfEmpty()
//select new {Cover = c.Cover,
// compNumber = o == null ? 0 : o.CompNumber
// }
from p in MurCompApplications
join o in MurCompCustomers on p.CompNumber equals o.CompNumber
join c in MurSapeliCovers on new { cid = o.CustId, coid=o.CoverId} equals new
{ c.CustomerId = cid, CoverId=coid} into g
from c in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from p in MurCompApplications
join q in MurCompCustomers on p.CompNumber equals q.CompNumber
select new
{
coverid = q.CoverId, compNumber = p.CompNumber
}
///////////////////////////////////
from p in MurCompApplications
join q in MurCompCustomers on p.CompNumber equals q.CompNumber into g
from q in g.DefaultIfEmpty()
select new
{
coverid = q == null ? 0 : q.CoverId,
compNumber = p.CompNumber
}
///////////////////////////////////
from c in MurSapeliCovers
join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
///////////////////////////////////
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from sapelicovers in TblCoverWithCustomerDetails
join compData in
(
from compCust in Comp_Customers
join compApp in Comp_Applications
on compCust.CompNumber equals compApp.Comp_CompNumber.CompNumber
where compApp.Active == true
&& compApp.Comp_TypeDetails.TypeId == 1
&& compApp.Comp_TypeDetails.Code == 1
select new
{
CompNumber = compCust.CompNumber,
CustId = compCust.CustId,
CoverId = compCust.CoverId,
IncidentDate = compApp.IncidentDate,
Active = compApp.Active,
CompTypeId = compApp.Comp_TypeDetails.TypeId,
CompTypeCode = compApp.Comp_TypeDetails.Code
}
)
on
new { coverno = sapelicovers.CoverNo , custid = sapelicovers.CustomerNo }
equals new { coverno = compData.CoverId , custid = compData.CustId }
into outer
from compData in outer.DefaultIfEmpty()
where sapelicovers.CustomerNo == 1
select new
{
Cover = sapelicovers.Cover,
InsuranceNumber = sapelicovers.InsuranceNo,
CompensationNumber = compData == null ? 0 : compData.CompNumber,
StatusCode = sapelicovers.CoverStatus,
EvaluationDate = compData.IncidentDate,
ExpiryReason = sapelicovers.ExpiryReason,
ValidFromDate = sapelicovers.CoverStartDate,
ValidToDate = sapelicovers.CoverEndDate,
SumInsured = sapelicovers.SumInsured,
Bonus = sapelicovers.BonusType,
Benificiary = sapelicovers.BeneficiaryCode
}
from sapelicover in TblCoverWithCustomerDetails
join o in
(
from p in Comp_Customers
join q in Comp_Applications
on p.CompNumber equals q.Comp_CompNumber.CompNumber
where q.Comp_TypeDetails.TypeId == 1
&& q.Comp_TypeDetails.Code == 1
&& p.CompNumber == 10005
&& q.Active == false
select new
{
coverid = p.CoverId,
CompNumber = p.CompNumber,
AddInfoReceivedDate = q.AddInfoReceivedDate,
AppReceivedDate = q.AppReceivedDate,
AddiInfo = q.Comments,
IncidentDate = q.IncidentDate,
CustId = p.CustId,
InsuranceNumber = p.InsuranceId
}
)
on new { coverid = sapelicover.CoverNo, custid = sapelicover.CustomerNo }
equals new { coverid = o.coverid, custid = o.CustId } into outer
from o in outer.DefaultIfEmpty()
where
sapelicover.Active == true
&& sapelicover.CustomerNo == 1
&& sapelicover.CoverNo == 1
select new
{
sapelicover, o
}
C# Expression
-------------
from p in Comp_Applications select p
from p in Comp_Applications select p.CompNumber
from p in Comp_Applications select new{p.RowId,p.CompNumber}
from p in Comp_Applications select new{Comp_Number=p.CompNumber}
from p in Comp_Applications select new{ rowid= p.RowId, comp_number= p.CompNumber}
from p in Comp_Applications where p.RowId > 10 select p
from p in Comp_Applications where p.CompNumber==10011 select p
from p in Comp_Applications where p.RowId > 10 && p.CompNumber==10011 select p
from p in Comp_Applications where p.RowId > 10 || p.CompNumber==10011 select p
from p in Comp_Applications orderby p.CreatedBy,p.CompNumber select p
from p in Comp_Applications group p by p.CreatedBy into g select new{ crea=g.Key}
from p in Comp_Applications group p by p.CreatedBy into g select new{ crea=g.Key, count=g.Count()}
var one = from p in Comp_Applications select p;
var two = from p in Comp_Applications select new{ rowid = p.RowId , compNumber = p.CompNumber };
one.Dump();
two.Dump();
from p in Comp_Applications
select new { p.CompNumber, CompeNumber = p.CompNumber > 10005 && p.CompNumber < 10008 ? 1 :
p.CompNumber > 10009 && p.CompNumber < 10020 ? 0:
p.CompNumber,
recDate = p.AppReceivedDate
}
outer join example:-
============================
create table MurCustomer
(
keyId int, customerName varchar(50)
)
create table MurOrder
(
keyId int, OrderNumber varchar(50)
)
insert into MurCustomer values(1,'xx');
insert into MurCustomer values(2,'yy');
insert into MurCustomer values(3,'zz');
insert into MurCustomer values(4,'aa');
insert into MurCustomer values(5,'bb');
insert into MurOrder values(1,'pppp');
insert into MurOrder values(1,'qqqq');
insert into MurOrder values(4,'rrrr');
insert into MurOrder values(5,'ssss');
insert into MurOrder values(5,'tttt');
select * from MurOrder;
select * from MurCustomer;
from c in MurCustomers
join o in MurOrders on c.KeyId equals o.KeyId into g
from o in g.DefaultIfEmpty()
select new {customerNameDisplay = c.CustomerName,
OrderNumber = o == null ? "(no orders)" : o.OrderNumber}
another example:-
===================
create table MurSapeliCover
(
CustomerId int, CoverId int, Cover varchar(50)
)
create table MurCompApplication
(
CompNumber int
)
create table MurCompCustomer
(
CompNumber int, CustId int, CoverId int
)
insert into MurSapeliCover values(1,1,'First cust 1st Cover');
insert into MurSapeliCover values(1,2,'First cust 2nd Cover');
insert into MurSapeliCover values(1,3,'First cust 3rd Cover');
insert into MurSapeliCover values(1,4,'First cust 4th Cover');
insert into MurSapeliCover values(2,1,'Second cust 1st Cover');
insert into MurSapeliCover values(2,5,'Second cust 2nd Cover');
insert into MurSapeliCover values(3,6,'Third cust 1st Cover');
insert into MurSapeliCover values(4,7,'Fourth cust 1st Cover');
insert into MurCompApplication values(1);
insert into MurCompApplication values(2);
insert into MurCompApplication values(3);
insert into MurCompCustomer values(1,1,1);
insert into MurCompCustomer values(2,1,2);
insert into MurCompCustomer values(3,2,1);
select * from MurSapeliCover;
select * from MurCompCustomer;
select * from MurCompApplication;
from c in MurSapeliCovers
join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from p in Comp_Customers where p.CustId == 100
select new { p, p.CompNumber, p.CustId }
ClaimsCRUD.GetCustomerSapeliCovers(request);
*/
-------------------------------
//from c in MurSapeliCovers
//join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
//{ cid = o.CustId, coid=o.CoverId} into g
//from o in g.DefaultIfEmpty()
//select new {Cover = c.Cover,
// compNumber = o == null ? 0 : o.CompNumber
// }
from p in MurCompApplications
join o in MurCompCustomers on p.CompNumber equals o.CompNumber
join c in MurSapeliCovers on new { cid = o.CustId, coid=o.CoverId} equals new
{ c.CustomerId = cid, CoverId=coid} into g
from c in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from p in MurCompApplications
join q in MurCompCustomers on p.CompNumber equals q.CompNumber
select new
{
coverid = q.CoverId, compNumber = p.CompNumber
}
///////////////////////////////////
from p in MurCompApplications
join q in MurCompCustomers on p.CompNumber equals q.CompNumber into g
from q in g.DefaultIfEmpty()
select new
{
coverid = q == null ? 0 : q.CoverId,
compNumber = p.CompNumber
}
///////////////////////////////////
from c in MurSapeliCovers
join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
///////////////////////////////////
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from sapelicovers in TblCoverWithCustomerDetails
join compData in
(
from compCust in Comp_Customers
join compApp in Comp_Applications
on compCust.CompNumber equals compApp.Comp_CompNumber.CompNumber
where compApp.Active == true
&& compApp.Comp_TypeDetails.TypeId == 1
&& compApp.Comp_TypeDetails.Code == 1
select new
{
CompNumber = compCust.CompNumber,
CustId = compCust.CustId,
CoverId = compCust.CoverId,
IncidentDate = compApp.IncidentDate,
Active = compApp.Active,
CompTypeId = compApp.Comp_TypeDetails.TypeId,
CompTypeCode = compApp.Comp_TypeDetails.Code
}
)
on
new { coverno = sapelicovers.CoverNo , custid = sapelicovers.CustomerNo }
equals new { coverno = compData.CoverId , custid = compData.CustId }
into outer
from compData in outer.DefaultIfEmpty()
where sapelicovers.CustomerNo == 1
select new
{
Cover = sapelicovers.Cover,
InsuranceNumber = sapelicovers.InsuranceNo,
CompensationNumber = compData == null ? 0 : compData.CompNumber,
StatusCode = sapelicovers.CoverStatus,
EvaluationDate = compData.IncidentDate,
ExpiryReason = sapelicovers.ExpiryReason,
ValidFromDate = sapelicovers.CoverStartDate,
ValidToDate = sapelicovers.CoverEndDate,
SumInsured = sapelicovers.SumInsured,
Bonus = sapelicovers.BonusType,
Benificiary = sapelicovers.BeneficiaryCode
}
from sapelicover in TblCoverWithCustomerDetails
join o in
(
from p in Comp_Customers
join q in Comp_Applications
on p.CompNumber equals q.Comp_CompNumber.CompNumber
where q.Comp_TypeDetails.TypeId == 1
&& q.Comp_TypeDetails.Code == 1
&& p.CompNumber == 10005
&& q.Active == false
select new
{
coverid = p.CoverId,
CompNumber = p.CompNumber,
AddInfoReceivedDate = q.AddInfoReceivedDate,
AppReceivedDate = q.AppReceivedDate,
AddiInfo = q.Comments,
IncidentDate = q.IncidentDate,
CustId = p.CustId,
InsuranceNumber = p.InsuranceId
}
)
on new { coverid = sapelicover.CoverNo, custid = sapelicover.CustomerNo }
equals new { coverid = o.coverid, custid = o.CustId } into outer
from o in outer.DefaultIfEmpty()
where
sapelicover.Active == true
&& sapelicover.CustomerNo == 1
&& sapelicover.CoverNo == 1
select new
{
sapelicover, o
}
C# Expression
-------------
from p in Comp_Applications select p
from p in Comp_Applications select p.CompNumber
from p in Comp_Applications select new{p.RowId,p.CompNumber}
from p in Comp_Applications select new{Comp_Number=p.CompNumber}
from p in Comp_Applications select new{ rowid= p.RowId, comp_number= p.CompNumber}
from p in Comp_Applications where p.RowId > 10 select p
from p in Comp_Applications where p.CompNumber==10011 select p
from p in Comp_Applications where p.RowId > 10 && p.CompNumber==10011 select p
from p in Comp_Applications where p.RowId > 10 || p.CompNumber==10011 select p
from p in Comp_Applications orderby p.CreatedBy,p.CompNumber select p
from p in Comp_Applications group p by p.CreatedBy into g select new{ crea=g.Key}
from p in Comp_Applications group p by p.CreatedBy into g select new{ crea=g.Key, count=g.Count()}
var one = from p in Comp_Applications select p;
var two = from p in Comp_Applications select new{ rowid = p.RowId , compNumber = p.CompNumber };
one.Dump();
two.Dump();
from p in Comp_Applications
select new { p.CompNumber, CompeNumber = p.CompNumber > 10005 && p.CompNumber < 10008 ? 1 :
p.CompNumber > 10009 && p.CompNumber < 10020 ? 0:
p.CompNumber,
recDate = p.AppReceivedDate
}
outer join example:-
============================
create table MurCustomer
(
keyId int, customerName varchar(50)
)
create table MurOrder
(
keyId int, OrderNumber varchar(50)
)
insert into MurCustomer values(1,'xx');
insert into MurCustomer values(2,'yy');
insert into MurCustomer values(3,'zz');
insert into MurCustomer values(4,'aa');
insert into MurCustomer values(5,'bb');
insert into MurOrder values(1,'pppp');
insert into MurOrder values(1,'qqqq');
insert into MurOrder values(4,'rrrr');
insert into MurOrder values(5,'ssss');
insert into MurOrder values(5,'tttt');
select * from MurOrder;
select * from MurCustomer;
from c in MurCustomers
join o in MurOrders on c.KeyId equals o.KeyId into g
from o in g.DefaultIfEmpty()
select new {customerNameDisplay = c.CustomerName,
OrderNumber = o == null ? "(no orders)" : o.OrderNumber}
another example:-
===================
create table MurSapeliCover
(
CustomerId int, CoverId int, Cover varchar(50)
)
create table MurCompApplication
(
CompNumber int
)
create table MurCompCustomer
(
CompNumber int, CustId int, CoverId int
)
insert into MurSapeliCover values(1,1,'First cust 1st Cover');
insert into MurSapeliCover values(1,2,'First cust 2nd Cover');
insert into MurSapeliCover values(1,3,'First cust 3rd Cover');
insert into MurSapeliCover values(1,4,'First cust 4th Cover');
insert into MurSapeliCover values(2,1,'Second cust 1st Cover');
insert into MurSapeliCover values(2,5,'Second cust 2nd Cover');
insert into MurSapeliCover values(3,6,'Third cust 1st Cover');
insert into MurSapeliCover values(4,7,'Fourth cust 1st Cover');
insert into MurCompApplication values(1);
insert into MurCompApplication values(2);
insert into MurCompApplication values(3);
insert into MurCompCustomer values(1,1,1);
insert into MurCompCustomer values(2,1,2);
insert into MurCompCustomer values(3,2,1);
select * from MurSapeliCover;
select * from MurCompCustomer;
select * from MurCompApplication;
from c in MurSapeliCovers
join o in MurCompCustomers on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from c in MurSapeliCovers
join o in ( from cu in MurCompCustomers join ca in MurCompApplications
on cu.CompNumber equals ca.CompNumber
select new { CustId = cu.CustId, CoverId = cu.CoverId, CompNumber=ca.CompNumber } )
on new { cid = c.CustomerId, coid=c.CoverId} equals new
{ cid = o.CustId, coid=o.CoverId} into g
from o in g.DefaultIfEmpty()
select new {Cover = c.Cover,
compNumber = o == null ? 0 : o.CompNumber
}
from p in Comp_Customers where p.CustId == 100
select new { p, p.CompNumber, p.CustId }
ClaimsCRUD.GetCustomerSapeliCovers(request);
*/
Sample LINQ Methods
public void SampleMethod()
{
DTOServices.Claims.Address FromAddress = new Sapeli.DTOServices.Claims.Address();
FromAddress.AddressKey = Guid.NewGuid();
FromAddress.City = "Bangalore";
FromAddress.Country = "India";
FromAddress.PAddress = "Mainroad, Marathahalli";
FromAddress.PostalCode = "560037";
DTOServices.Claims.Address ToAddress = new Sapeli.DTOServices.Claims.Address();
PropertyInfo[] propFrom = FromAddress.GetType().GetProperties();
PropertyInfo[] propTo = ToAddress.GetType().GetProperties();
foreach (PropertyInfo p in propFrom)
{
object value = p.GetValue(FromAddress, new object[] { });
//propTo.SetValue(value, 1);
}
//using (InsuranceEntities ctx = new InsuranceEntities())
//{
// var qry = from efcover in ctx.BeneficiaryItem.Include("Beneficiary").Include("Beneficiary.Cover").Include("BeneficiaryTable")
// where efcover.Beneficiary.Cover.ID == new Guid("") && (efcover.RowStatus == 600 || efcover.RowStatus == 900) &&
// efcover.Beneficiary.OrderInsuredIn == 1
// select efcover;
// var qry1 = from p in ctx.BeneficiaryItem.Include("Beneficiary")
// where p.Beneficiary.Cover.ID == new Guid("") select p;
//}
//using (SapeliPrintEntities ctx = new SapeliPrintEntities())
//{
// var qry = from p in ctx.CaseType.Include("Case")
// where p.Case
//}
//using (SapeliPrintEntities insurancePrint = new SapeliPrintEntities())
//{
// CaseType casetype;
//casetype = (from p in insurancePrint.CaseType.Include("Case")
// where p.ID == new Guid("F471F3AA-6804-4871-9B5F-88237234BF42")
// && p.Case.SelectMany( o => o.CaseCreated.Value.Day < 10)
// select p).FirstOrDefault();
//if (casetype != null)
//{
// //casetype.Case.Where(o => o.CaseCreated.Value.Day < 10);
// //casetype.Case.Load();
// //casetype.Case.Attach( casetype.Case.CreateSourceQuery().Where(o=> o.CaseCreated.Value.Day < 10 ));
// //casetype.CoverItem.Attach(cover.CoverItem.CreateSourceQuery().Where(o => o.RowStatus == 600));
//}
//var roles = from role in ctx.InsuranceRole.Include("InsuranceRoleItem")
// where role.RowStatus == 600 &&
// role.fk_Covers == coverid
// select role;
//foreach (InsuranceRole role in roles)
//{
// role.RowStatus = 900;
// foreach (InsuranceRoleItem item in role.InsuranceRoleItem.Where(o => o.RowStatus == 600))
// {
// item.RowStatus = 900;
// }
//}
//using (Sapeli_InvoiceEntities ctx = new Sapeli_InvoiceEntities())
//{
// IEnumerable invoices = ctx.CreateQuery(query).ToList().DefaultIfEmpty();
// return invoices.ToList();
//}
//var invoice = ctx.Invoice.Include("InvoiceAmount")
// .Where(i => i.InsuranceNo == insuranceNo)
// .Where(i => i.InvoiceStartDate < searchDate)
// .Where(i => i.InvoiceEndDate > searchDate).ToList().DefaultIfEmpty();
//var qry = insurancePrint.CaseType.Where(p => p.CaseCode != "");
//IEnumerable
//objCaseCollection = from p in insurancePrint.CaseType.Include("Case") //.Include("CaseType")
// select p;
//foreach (CaseType objCase in objCaseCollection)
//{
//}
//var qry1 = (from p in insurancePrint.CaseType select p).FirstOrDefault();
//qry1.Case.Load();
//foreach (CaseType obj in objCaseCollection)
//{
//}
//// IEnumerable results = ctx.CreateQuery ("SELECT * FROM [Sapeli_Invoice].[dbo].[Invoice]");
// var qry = from p in insurancePrint.CaseType select p;
// //IEnumerable objFilter = objCaseCollection.Where(p => p.CaseCode == "703");
// //IEnumerable
// //objCaseCollection = from p in insurancePrint.MasterInsurance.Include("InsuranceRole").Include("InsuranceRole.InsuranceRoleItem").Include("InsuranceRole.InsuranceRoleContactInfo")
// // select p;
// foreach (CaseType objCase in objCaseCollection)
//{
//}
//}
}
{
DTOServices.Claims.Address FromAddress = new Sapeli.DTOServices.Claims.Address();
FromAddress.AddressKey = Guid.NewGuid();
FromAddress.City = "Bangalore";
FromAddress.Country = "India";
FromAddress.PAddress = "Mainroad, Marathahalli";
FromAddress.PostalCode = "560037";
DTOServices.Claims.Address ToAddress = new Sapeli.DTOServices.Claims.Address();
PropertyInfo[] propFrom = FromAddress.GetType().GetProperties();
PropertyInfo[] propTo = ToAddress.GetType().GetProperties();
foreach (PropertyInfo p in propFrom)
{
object value = p.GetValue(FromAddress, new object[] { });
//propTo.SetValue(value, 1);
}
//using (InsuranceEntities ctx = new InsuranceEntities())
//{
// var qry = from efcover in ctx.BeneficiaryItem.Include("Beneficiary").Include("Beneficiary.Cover").Include("BeneficiaryTable")
// where efcover.Beneficiary.Cover.ID == new Guid("") && (efcover.RowStatus == 600 || efcover.RowStatus == 900) &&
// efcover.Beneficiary.OrderInsuredIn == 1
// select efcover;
// var qry1 = from p in ctx.BeneficiaryItem.Include("Beneficiary")
// where p.Beneficiary.Cover.ID == new Guid("") select p;
//}
//using (SapeliPrintEntities ctx = new SapeliPrintEntities())
//{
// var qry = from p in ctx.CaseType.Include("Case")
// where p.Case
//}
//using (SapeliPrintEntities insurancePrint = new SapeliPrintEntities())
//{
// CaseType casetype;
//casetype = (from p in insurancePrint.CaseType.Include("Case")
// where p.ID == new Guid("F471F3AA-6804-4871-9B5F-88237234BF42")
// && p.Case.SelectMany( o => o.CaseCreated.Value.Day < 10)
// select p).FirstOrDefault();
//if (casetype != null)
//{
// //casetype.Case.Where(o => o.CaseCreated.Value.Day < 10);
// //casetype.Case.Load();
// //casetype.Case.Attach( casetype.Case.CreateSourceQuery().Where(o=> o.CaseCreated.Value.Day < 10 ));
// //casetype.CoverItem.Attach(cover.CoverItem.CreateSourceQuery().Where(o => o.RowStatus == 600));
//}
//var roles = from role in ctx.InsuranceRole.Include("InsuranceRoleItem")
// where role.RowStatus == 600 &&
// role.fk_Covers == coverid
// select role;
//foreach (InsuranceRole role in roles)
//{
// role.RowStatus = 900;
// foreach (InsuranceRoleItem item in role.InsuranceRoleItem.Where(o => o.RowStatus == 600))
// {
// item.RowStatus = 900;
// }
//}
//using (Sapeli_InvoiceEntities ctx = new Sapeli_InvoiceEntities())
//{
// IEnumerable
// return invoices.ToList();
//}
//var invoice = ctx.Invoice.Include("InvoiceAmount")
// .Where(i => i.InsuranceNo == insuranceNo)
// .Where(i => i.InvoiceStartDate < searchDate)
// .Where(i => i.InvoiceEndDate > searchDate).ToList().DefaultIfEmpty();
//var qry = insurancePrint.CaseType.Where(p => p.CaseCode != "");
//IEnumerable
//objCaseCollection = from p in insurancePrint.CaseType.Include("Case") //.Include("CaseType")
// select p;
//foreach (CaseType objCase in objCaseCollection)
//{
//}
//var qry1 = (from p in insurancePrint.CaseType select p).FirstOrDefault();
//qry1.Case.Load();
//foreach (CaseType obj in objCaseCollection)
//{
//}
//// IEnumerable
// var qry = from p in insurancePrint.CaseType select p;
// //IEnumerable
// //IEnumerable
// //objCaseCollection = from p in insurancePrint.MasterInsurance.Include("InsuranceRole").Include("InsuranceRole.InsuranceRoleItem").Include("InsuranceRole.InsuranceRoleContactInfo")
// // select p;
// foreach (CaseType objCase in objCaseCollection)
//{
//}
//}
}
Subscribe to:
Posts (Atom)