Friday, October 1, 2010

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)
//{

//}
//}
}

No comments:

Post a Comment