Friday, July 27, 2012

Sample Linq queries

http://msdn.microsoft.com/en-us/vstudio/bb688084.aspx
var queryAllCustomers = from cust in customers
select cust;

var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;



var queryLondonCustomers = from cust in customers
where cust.City == "London"
select cust;

Grouping
// queryCustomersByCity is an IEnumerable>
var queryCustomersByCity =
from cust in customers
group cust by cust.City;

// customerGroup is an IGrouping
foreach (var customerGroup in queryCustomersByCity)
{
Console.WriteLine(customerGroup.Key);
foreach (Customer customer in customerGroup)
{
Console.WriteLine(" {0}", customer.Name);

}
}
// custQuery is an IEnumerable>
var custQuery =
from cust in customers
group cust by cust.City into custGroup
where custGroup.Count() > 2
orderby custGroup.Key
select custGroup;



var innerJoinQuery =
from cust in customers
join dist in distributors on cust.City equals dist.City
select new { CustomerName = cust.Name, DistributorName = dist.Name };





Complex Ling query with inner joins
from pListNames in _etblPriceListNames
join priceListPrices in _etblPriceListPrices on new { PL = pListNames.IDPriceListName } equals new { PL = priceListPrices.IPriceListNameID }
join client in Clients on new { C = pListNames.IDPriceListName } equals new { C = (int)client.IARPriceListNameID }
join sales in SalesReps on new { S = (int)client.RepID } equals new { S = (int)sales.IdSalesRep }
join stkitem in StkItems on new { STK = priceListPrices.IStockID } equals new { STK = stkitem.StockLink }
join grptbl in GrpTbls on new { GRP = stkitem.ItemGroup } equals new { GRP = grptbl.StGroup }
join whseStk in WhseStks on new { WHE = stkitem.StockLink } equals new { WHE = whseStk.WHStockLink }
join whseMST in WhseMsts on new { wMST = (int)whseStk.WHWhseID } equals new { wMST = (int)whseMST.WhseLink }
where (stkitem.ItemActive == true) && (stkitem.WhseItem == true) &&
(client.On_Hold == false) &&
stkitem.UlIISubCategory == "Samsung" &&
stkitem.UlIISubCategory != null &&
stkitem.UlIISubCategory != " " &&
stkitem.Code == "BATSAB3310L" &&
grptbl.Description == "BATTERIES" &&
client.Account == "CEL07" &&
whseMST.Code == "ZZZ" &&
whseStk.WHQtyOnHand > 0
orderby
pListNames.CDescription,
grptbl.Description, stkitem.UlIISubCategory,
stkitem.Code, client.Account
select new
{ warehouse = whseMST.Code, pricelist = pListNames.CDescription, ItemGroup = grptbl.Description, SubCategory = stkitem.UlIISubCategory, StockCode = stkitem.Code, Description = stkitem.Description_1, ClientAccount = client.Account, CompanyName = client.Name, SalesRep = sales.Name, ExclPrice = priceListPrices.FExclPrice, fInclPrice = priceListPrices.FInclPrice, QTYOnHand = whseStk.WHQtyOnHand, QTYOnSalesOrders = whseStk.WHQtyOnSO, QTYOnPurchaseOrders = whseStk.WHQtyOnPO } }

Friday, July 20, 2012

Access Command Line Arguments in C#

www.c-sharpcorner.com/uploadfile/mahesh/cmdlineargs03212006232449pm/cmdlineargs.aspx

Thursday, July 19, 2012

Add webreference in windows application

Adding web reference in C# Windows app
Steps
1:Add the below lines in app.config file
then go to solution explorer,click on add services reference
2:click on advanced button
3:then click add web reference
4:then add respective web reference

Friday, July 13, 2012

Renaming table sql:

sp_rename 'old_table_name', new_table_name'

delete a service from services when it is no longer used or still resent in services after uninstalling it

delete a service from services when it is no longer used or still resent in services after uninstalling it sc.exe delete < service name > OR Just delete it from registery

Thursday, July 5, 2012

Paging in RDLC

=Int((RowNumber(Nothing)-1)/8) add a group to your table in Report by going to table properties and then add the above line