void method3() { // <Snippet3> Northwnd db = new Northwnd(@"c:\northwnd.mdf"); db.DeferredLoadingEnabled = false; DataLoadOptions ds = new DataLoadOptions(); ds.LoadWith <Customer>(c => c.Orders); ds.LoadWith <Order>(o => o.OrderDetails); db.LoadOptions = ds; var custQuery = from cust in db.Customers where cust.City == "London" select cust; foreach (Customer custObj in custQuery) { Console.WriteLine("Customer ID: {0}", custObj.CustomerID); foreach (Order ord in custObj.Orders) { Console.WriteLine("\tOrder ID: {0}", ord.OrderID); foreach (OrderDetail detail in ord.OrderDetails) { Console.WriteLine("\t\tProduct ID: {0}", detail.ProductID); } } } // </Snippet3> }
public Activity GetActivity(int activityID) { bizMessage biz = new bizMessage(); try { enGageDataContext db = new enGageDataContext(); DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Activity>(act => act.Opportunity); loadOptions.LoadWith <Opportunity>(opp => opp.Client); db.LoadOptions = loadOptions; Activity a; a = db.Activities.SingleOrDefault(ac => ac.ActivityID == activityID); if (a == null) { this.MSGS.AddMessage(biz.GetMessageText("EmptyRecord"), Enums.enMsgType.Err); } return(a); } catch (Exception ex) { this.MSGS.AddMessage(biz.GetMessageText("Exception"), Enums.enMsgType.Err); bizLog.InsertExceptionLog(ex); return(null); } }
public IEnumerable <Production> GetNonClosedProductions() { using (var context = new ManufacturingDataContext(_connectionString)) { var loadOptions = new DataLoadOptions(); //loadOptions.LoadWith<CuttingInstruction>(p => p.CuttingInstructionItems); loadOptions.LoadWith <CuttingInstruction>(p => p.ReceivingItemsTransactions); loadOptions.LoadWith <Production>(p => p.CuttingInstructions); context.LoadOptions = loadOptions; var prods = new List <Production>(); foreach (var productin in context.Productions.Where(p => !p.CuttingInstructions.All(i => i.Completed == true))) { if (productin.CuttingInstructions.Count() > 0) { var CuttingInstructionItemsSum = productin.CuttingInstructions.Where(c => c.CuttingInstructionDetails.Count() > 0).Sum(c => c.CuttingInstructionDetails.Sum(cd => cd.CuttingInstructionItems.Sum(d => d.Quantity))); var recivedItemSum = productin.CuttingInstructions.Where(c => c.ReceivingItemsTransactions.Count() > 0).Sum(c => c.ReceivingItemsTransactions.Sum(cd => cd.Quantity)); if (CuttingInstructionItemsSum != recivedItemSum) { prods.Add(productin); } } } return(prods.ToList()); } }
private static void ReadPerformance(int count, int times) { Console.WriteLine("--------------Testing reading performance--------------"); var ef = Timer.Time(() => { using (var context = EfContextFactory.CreateContext()) { context.Messages.AsNoTracking().OrderBy(f => f.Id).Take(count) .Include(f => f.Owner).Include(f => f.Sender).Include(f => f.Receiver) .ToList(); } }, times); var linq2Sql = Timer.Time(() => { using (var context = Linq2SqlContextFactory.CreateContext()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith <Linq2Sql.Message>(c => c.Owner); options.LoadWith <Linq2Sql.Message>(c => c.Sender); options.LoadWith <Linq2Sql.Message>(c => c.Reciever); context.LoadOptions = options; context.Messages.OrderBy(f => f.Id).Take(count).ToList(); } }, times); Console.WriteLine("Ef: {0}, Linq2sql: {1}", ef, linq2Sql); }
public Inti_AthleteClub GetAthleteClubByTournament(Guid athleteId, Guid tournamentId) { using (var db = new IntiDataContext(_connectionString)) { var dlo = new DataLoadOptions(); dlo.LoadWith <Inti_AthleteClub>(ac => ac.Inti_Club); dlo.LoadWith <Inti_AthleteClub>(ac => ac.Inti_Position); dlo.LoadWith <Inti_AthleteClub>(ac => ac.Inti_Athlete); db.LoadOptions = dlo; var athleteClubs = from ac in db.Inti_AthleteClub where ac.AthleteGUID == athleteId && ac.Inti_Club.TournamentGUID == tournamentId select ac; if (athleteClubs.ToList().Count == 1) { var athleteClub = athleteClubs.ToList()[0]; return(athleteClub); } if (athleteClubs.ToList().Count > 1) { throw new ArgumentException("More than one club for the athlete with id {0} in the same tournament.", athleteId.ToString()); } } return(null); }
private static void HandleUserInvestedMsg(int projectTransactionId) { var now = DateTime.Now; var startTime = new DateTime(2015, 5, 3); if (startTime <= now.Date /*&& now.Date <= startTime.AddMonths(6)*/) // 判断是否活动期间 { var context = new Agp2pDataContext(); var options = new DataLoadOptions(); options.LoadWith <li_project_transactions>(p => p.dt_users); options.LoadWith <dt_users>(p => p.li_invitations); context.LoadOptions = options; var investment = context.li_project_transactions.Single(tr => tr.id == projectTransactionId); if (investment.li_projects.IsNewbieProject1()) { // 投资新手标不算 return; } // 用户只能有一个邀请人,所有一对一关系就是被邀请记录,一对多关系的是邀请记录 var investor = investment.dt_users; if (investor.li_invitations == null || investor.li_invitations.li_project_transactions != null) { return; // 没有邀请人或已经记录过首次投资 } investor.li_invitations.li_project_transactions = investment; // 利润和收益时间需要等满标后才能计算 context.SubmitChanges(); } }
public override void PostRepoInit() { var options = new DataLoadOptions(); options.LoadWith<Sat>(s => s.User); options.LoadWith<User>(u => u.Tags); _repo.LoadOptions = options; }
public virtual List <Course> AllCoursesForList() { var localContext = new SpecialistDataContext(); var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Course>(c => c.CourseLanguages); loadOptions.LoadWith <CourseLanguage>(c => c.Language); localContext.LoadOptions = loadOptions; var result = localContext.Courses.IsActive().Select(c => new { c.Course_ID, c.Course_TC, c.IsTrack, c.UrlName, c.WebName, c.IsNew, c.WebPublishSchedule, c.Name, c.WebShortName, c.CourseDirectionA_TC, c.BaseHours, c.AdditionalHours, c.IntraExtramuralHours, c.IntraExtramuralHoursOut, Languages = c.CourseLanguages.Select(x => x.Language_TC), TrackFirstCourseTC = c.TrackCourses.OrderBy(t => t.SortOrder) .Select(t => t.Course.Course_TC).FirstOrDefault() }).ToList().GroupBy(c => c.UrlName).Select(x => x.OrderBy(y => y.Course_ID).First()); return(result.Select(c => { var courseLanguages = new EntitySet <CourseLanguage>(); courseLanguages.AddRange(c.Languages.Select(ln => new CourseLanguage { Language = new Language { Language_TC = ln } })); return new Course { Course_ID = c.Course_ID, Course_TC = c.Course_TC, UrlName = c.UrlName, IsNew = c.IsNew, WebPublishSchedule = c.WebPublishSchedule, WebName = c.WebName, CourseDirectionA_TC = c.CourseDirectionA_TC, Name = c.Name, IsTrack = c.IsTrack, WebShortName = c.WebShortName, BaseHours = c.BaseHours, AdditionalHours = c.AdditionalHours, IntraExtramuralHours = c.IntraExtramuralHours, IntraExtramuralHoursOut = c.IntraExtramuralHoursOut, CourseLanguages = courseLanguages, TrackFirstCourseTC = c.TrackFirstCourseTC }; }).ToList()); }
internal Recipe[] GetUserFavoritesRecipes(int userId) { using (DataContext) { try { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith <Recipe>(r => r.User); dlo.LoadWith <Recipe>(r => r.UserFavoriteRecipes); dlo.LoadWith <Recipe>(r => r.MenuRecipes); dlo.LoadWith <Recipe>(r => r.RecipeCategories); dlo.LoadWith <RecipeCategory>(rc => rc.Category); DataContext.LoadOptions = dlo; var list = from r in DataContext.Recipes join ufr in DataContext.UserFavoriteRecipes.Where(ufr => ufr.UserId == userId) on r.RecipeId equals ufr.RecipeId select r; return(list.ToArray()); } catch { return(null); } } }
private SettingsModel GetModel() { var model = new SettingsModel(); model.SchemeName = "SimpleWF"; using (var context = new DataModelDataContext()) { var lo = new DataLoadOptions(); lo.LoadWith <Employee>(c => c.StructDivision); lo.LoadWith <EmployeeRole>(c => c.Role); lo.LoadWith <Employee>(c => c.EmployeeRoles); context.LoadOptions = lo; var wfSheme = context.WorkflowSchemes.FirstOrDefault(c => c.Code == model.SchemeName); if (wfSheme != null) { model.WFSchema = wfSheme.Scheme; } model.Employees = context.Employees.ToList(); model.Roles = context.Roles.ToList(); model.StructDivision = context.StructDivisions.ToList(); } return(model); }
public IEnumerable <DataTransfer.Problem> GetProblems(string platformName) { roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); using (OKBDataContext okb = new OKBDataContext()) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith <Problem>(x => x.ProblemClass); dlo.LoadWith <Problem>(x => x.DataType); dlo.LoadWith <Problem>(x => x.ProblemUsers); okb.LoadOptions = dlo; var query = okb.Problems.Where(x => x.Platform.Name == platformName); List <Problem> results = new List <Problem>(); if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { results.AddRange(query); } else { foreach (var problem in query) { if (problem.ProblemUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, problem.ProblemUsers.Select(y => y.UserGroupId).ToList())) { results.Add(problem); } } } return(results.Select(x => Convert.ToDto(x)).ToArray()); } }
public IEnumerable <ExpirationItem> GetMemberDetails(int userid, int companyid) { using (DataLayerDataContext db = new DataLayerDataContext()) { var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <ExpirationItem>(p => p.User); loadOptions.LoadWith <User>(p => p.CoreCourses); loadOptions.LoadWith <User>(p => p.Courses); loadOptions.LoadWith <CoreCourse>(p => p.CourseCategory); loadOptions.LoadWith <ExpirationItem>(p => p.Category); db.LoadOptions = loadOptions; IEnumerable <OrgRequiredItem> o = db.OrgRequiredItems.Where(i => i.OrgId == companyid); IEnumerable <ExpirationItem> e = db.ExpirationItems.Where(i => i.UserId == userid); List <ExpirationItem> list = new List <ExpirationItem>(); foreach (ExpirationItem i in e) { foreach (OrgRequiredItem r in o) { if (i.CategoryId == r.CatId) { list.Add(i); } } } return(list.ToList()); } }
public static void SetChildLoadOptions(DataLoadOptions loadOptions) { loadOptions.LoadWith <ForeignCitizenData>(fcd => fcd.BirthCountryRef); loadOptions.LoadWith <ForeignCitizenData>(fcd => fcd.ForeignCitizenCountries); ForeignCitizenCountry.SetChildLoadOptions(loadOptions); }
public Client GetClient(int clientID) { bizMessage biz = new bizMessage(); try { enGageDataContext db = new enGageDataContext(); DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Client>(o => o.Contacts); loadOptions.LoadWith <Client>(o => o.Opportunities); db.LoadOptions = loadOptions; Client c; c = db.Clients.SingleOrDefault(cli => cli.ClientID == clientID); if (c == null) { this.MSGS.AddMessage(biz.GetMessageText("EmptyRecord"), Enums.enMsgType.Err); } return(c); } catch (Exception ex) { this.MSGS.AddMessage(biz.GetMessageText("Exception"), Enums.enMsgType.Err); bizLog.InsertExceptionLog(ex); return(null); } }
public IEnumerable <POCO.TrnSales> GetSalesReport(DateTime date) { IEnumerable <POCO.TrnSales> result; var firstDayOfMonth = new DateTime(date.Year, date.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); var mappingProfile = new MappingProfileForTrnSales(); using (var ctx = new posDataContext()) { ctx.DeferredLoadingEnabled = false; var trnSalesIncludes = new DataLoadOptions(); trnSalesIncludes.LoadWith <Data.TrnSale>(x => x.TrnSalesLines); trnSalesIncludes.LoadWith <Data.TrnSale>(x => x.MstCustomer); trnSalesIncludes.LoadWith <Data.TrnSalesLine>(x => x.MstItem); ctx.LoadOptions = trnSalesIncludes; result = mappingProfile.mapper.Map <List <POCO.TrnSales> >(ctx.TrnSales .Where(x => x.SalesDate >= firstDayOfMonth && x.SalesDate <= lastDayOfMonth)); } return(result); }
public IEnumerable<DataTransfer.Algorithm> GetAlgorithms(string platformName) { roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); using (OKBDataContext okb = new OKBDataContext()) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Algorithm>(x => x.AlgorithmClass); dlo.LoadWith<Algorithm>(x => x.DataType); dlo.LoadWith<Algorithm>(x => x.AlgorithmUsers); okb.LoadOptions = dlo; var query = okb.Algorithms.Where(x => x.Platform.Name == platformName); List<Algorithm> results = new List<Algorithm>(); if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { results.AddRange(query); } else { foreach (var alg in query) { if (alg.AlgorithmUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, alg.AlgorithmUsers.Select(y => y.UserGroupId).ToList())) { results.Add(alg); } } } return results.Select(x => Convert.ToDto(x)).ToArray(); } }
internal static List <item> Get(string cat) { using (var db = new DataClassesDataContext()) { //return db.items.Where(i => i[cat] != null).ToList(); DataLoadOptions options = new DataLoadOptions(); switch (cat) { case "attractions": options.LoadWith <item>(t => t.attraction); db.LoadOptions = options; return(db.items.Where(i => i.attraction != null).ToList()); case "shows": options.LoadWith <item>(t => t.show); db.LoadOptions = options; return(db.items.Where(i => i.show != null).ToList()); case "restaurants": options.LoadWith <item>(t => t.restaurant); db.LoadOptions = options; return(db.items.Where(i => i.restaurant != null).ToList()); default: throw new Exception("no such category"); } } }
static void Listing14_11() { Console.WriteLine("{0} : Begin", new StackTrace(0, true).GetFrame(0).GetMethod().Name); Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;"); DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith <Customer>(c => c.Orders); dlo.LoadWith <Order>(o => o.OrderDetails); db.LoadOptions = dlo; IQueryable <Customer> custs = (from c in db.Customers where c.Country == "UK" && c.City == "London" orderby c.CustomerID select c); // Turn on the logging. db.Log = Console.Out; foreach (Customer cust in custs) { Console.WriteLine("{0} - {1}", cust.CompanyName, cust.ContactName); } Console.WriteLine("{0} : End", new StackTrace(0, true).GetFrame(0).GetMethod().Name); }
public ActionResult GetByEdiOrder(int ediOrderID) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith <Concentrator.Objects.EDI.Order.EDIOrder>(o => o.ShipToCustomer); options.LoadWith <Concentrator.Objects.EDI.Order.EDIOrder>(o => o.SoldToCustomer); var soldCust = GetObject <Objects.EDI.Order.EDIOrder>(c => c.EdiOrderID == ediOrderID, options).SoldToCustomer; var shipCust = GetObject <Objects.EDI.Order.EDIOrder>(c => c.EdiOrderID == ediOrderID, options).ShipToCustomer; if (soldCust != null) { return(Json(new { customer = new { City = soldCust != null ? soldCust.City : shipCust.City, Country = soldCust != null ? soldCust.Country : shipCust.Country, CustomerAddressLine1 = soldCust != null ? soldCust.CustomerAddressLine1 : shipCust.CustomerAddressLine1, CustomerAddressLine2 = soldCust != null ? soldCust.CustomerAddressLine2 : shipCust.CustomerAddressLine2, CustomerAddressLine3 = soldCust != null ? soldCust.CustomerAddressLine3 : shipCust.CustomerAddressLine3, CustomerEmail = soldCust != null ? soldCust.CustomerEmail : shipCust.CustomerEmail, CustomerName = soldCust != null ? soldCust.CustomerName : shipCust.CustomerName, CustomerTelephone = soldCust != null ? soldCust.CustomerTelephone : shipCust.CustomerTelephone, EANIdentifier = soldCust != null ? soldCust.EANIdentifier : shipCust.EANIdentifier, PostCode = soldCust != null ? soldCust.PostCode : shipCust.PostCode, ShipCity = shipCust.City, ShipCountry = shipCust.Country, ShipCustomerAddressLine1 = shipCust.CustomerAddressLine1, ShipCustomerAddressLine2 = shipCust.CustomerAddressLine2, ShipCustomerAddressLine3 = shipCust.CustomerAddressLine3, ShipCustomerEmail = shipCust.CustomerEmail, ShipCustomerName = shipCust.CustomerName, ShipCustomerTelephone = shipCust.CustomerTelephone, ShipEANIdentifier = shipCust.EANIdentifier, ShipPostCode = shipCust.PostCode, } })); } else { return(Json(new { customer = new { ShipCity = shipCust.City, ShipCountry = shipCust.Country, ShipCustomerAddressLine1 = shipCust.CustomerAddressLine1, ShipCustomerAddressLine2 = shipCust.CustomerAddressLine2, ShipCustomerAddressLine3 = shipCust.CustomerAddressLine3, ShipCustomerEmail = shipCust.CustomerEmail, ShipCustomerName = shipCust.CustomerName, ShipCustomerTelephone = shipCust.CustomerTelephone, ShipEANIdentifier = shipCust.EANIdentifier, ShipPostCode = shipCust.PostCode } })); } }
public ActionResult Details(int id) { IPFinalDBDataContext finalDB = new IPFinalDBDataContext(); DataLoadOptions ds = new DataLoadOptions(); ds.LoadWith <Work_Package>(wp => wp.Package_Softwares); ds.LoadWith <Package_Software>(ps => ps.Software_Requirement); finalDB.LoadOptions = ds; var pack = (from p in finalDB.Work_Packages where p.id == id select p).Single(); //var data = from sr in finalDB.Software_Requirements // join ps in finalDB.Package_Softwares // on sr.id equals ps.sr_id // where ps.wp_id == id // select sr; //foreach (var ps in data) //{ // pack.Package_Softwares.Add(new Package_Software() // { // Software_Requirement = ps, // Work_Package = pack // }); //} return(View(pack)); }
public void LoadWith_Good2() { var lo = new DataLoadOptions(); lo.LoadWith <Order>(o => o.Employee); lo.LoadWith <Customer>(c => c.Orders); }
public static StarMap GetMapData(string playerName, string password) { var db = new DbDataContext(); var ret = new StarMap(); var lo = new DataLoadOptions(); lo.LoadWith <CelestialObject>(x => x.CelestialObjectShips); // todo stealth also in all fleet structures lo.LoadWith <CelestialObject>(x => x.CelestialObjectStructures); db.LoadOptions = lo; ret.CelestialObjects = db.CelestialObjects.ToList(); ret.Players = db.Players.Where(x => x.IsActive).ToList(); ret.StarSystems = db.StarSystems.ToList(); ret.Transits = FleetLogic.GetTransits(playerName, password); ret.Config = db.GetConfig(); ret.ObjectLinks = db.CelestialObjectLinks.ToList(); return(ret); }
public void LinqToSqlObject04() { var db = CreateDB(); var ds = new DataLoadOptions(); ds.LoadWith <Customer>(p => p.Orders); ds.LoadWith <Order>(p => p.OrderDetails); db.LoadOptions = ds; var custs = from c in db.Customers where c.City == "London" select c; foreach (var cust in custs) { foreach (var ord in cust.Orders) { foreach (var orderDetail in ord.OrderDetails) { Console.WriteLine("CustomerID {0} has an OrderID {1} with ProductID {2} that has name {3}.", cust.CustomerID, ord.OrderID, orderDetail.ProductID, orderDetail.Product.ProductName); } } } var list = custs.ToList(); Assert.IsTrue(list.Count > 0); }
public ActionResult Details(int id) { IPFinalDBDataContext finalDB = new IPFinalDBDataContext(); DataLoadOptions ds = new DataLoadOptions(); ds.LoadWith<Work_Package>(wp => wp.Package_Softwares); ds.LoadWith<Package_Software>(ps => ps.Software_Requirement); finalDB.LoadOptions = ds; var pack = (from p in finalDB.Work_Packages where p.id == id select p).Single(); //var data = from sr in finalDB.Software_Requirements // join ps in finalDB.Package_Softwares // on sr.id equals ps.sr_id // where ps.wp_id == id // select sr; //foreach (var ps in data) //{ // pack.Package_Softwares.Add(new Package_Software() // { // Software_Requirement = ps, // Work_Package = pack // }); //} return View(pack); }
//[TestMethod()] public void Command_Should_Parse_Correctly() { // ARRANGE Character toon = null; InventoryItem invItem = new InventoryItem(); // Get the client's character info string charName = "Badass"; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Character>(c => c.Account); dlo.LoadWith<Character>(c => c.Zone); dlo.LoadWith<Character>(c => c.InventoryItems); dlo.LoadWith<InventoryItem>(ii => ii.Item); using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; dbCtx.LoadOptions = dlo; toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName); } ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123))); // ACT //zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage /amount:200 /type:3", 8, 0, 100); zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage", 8, 0, 100); // ASSERT }
public Inti_AthleteClub GetAthleteClubByTournament(Guid athleteId, Guid tournamentId) { using (var db = new IntiDataContext(_connectionString)) { var dlo = new DataLoadOptions(); dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Club); dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Position); dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Athlete); db.LoadOptions = dlo; var athleteClubs = from ac in db.Inti_AthleteClub where ac.AthleteGUID == athleteId && ac.Inti_Club.TournamentGUID == tournamentId select ac; if(athleteClubs.ToList().Count == 1) { var athleteClub = athleteClubs.ToList()[0]; return athleteClub; } if (athleteClubs.ToList().Count > 1) { throw new ArgumentException("More than one club for the athlete with id {0} in the same tournament.", athleteId.ToString()); } } return null; }
public void LoadWith_BadCycles1() { var lo = new DataLoadOptions(); lo.LoadWith <Customer>(c => c.Orders); lo.LoadWith <Order>(o => o.Customer); }
internal MealRecipe[] GetMealRecipesList(int menuId, int dayIndex, int mealTypeId) { using (DataContext) { try { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith <MealRecipe>(mr => mr.Meal); dlo.LoadWith <MealRecipe>(mr => mr.Recipe); DataContext.LoadOptions = dlo; var meals = DataContext.Meals.Where(m => m.MenuId == menuId && m.DayIndex == dayIndex && m.MealTypeId == mealTypeId); var list = from mr in DataContext.MealRecipes join m in meals on mr.MealId equals m.MealId select mr; return(list.ToArray()); } catch { return(null); } } }
public TaskRecord GetTaskRecord(int id) { using (var sqlWrapper = new SqlQueryWrapper(_connStr)) { TaskRecord taskRecord = null; sqlWrapper.Run((db) => { var options = new DataLoadOptions(); options.LoadWith <TaskRecord>(t => t.User); options.LoadWith <TaskRecord>(t => t.User1); options.LoadWith <TaskRecord>(t => t.Client); options.LoadWith <TaskRecord>(t => t.Analyses_Equipment); options.LoadWith <Analyses_Equipment>(ae => ae.Equipment); options.LoadWith <Equipment>(e => e.Building); options.LoadWith <Equipment>(e => e.EquipmentType); options.LoadWith <EquipmentType>(et => et.EquipmentClass); options.LoadWith <Building>(b => b.State); options.LoadWith <Building>(b => b.Country); db.LoadOptions = options; taskRecord = db.TaskRecords.SingleOrDefault(t => t.TaskID == id); }); return(taskRecord); } }
private bool CheckLimitSighting(ServiceIdentity identity, Guid instanceId, SightingType type) { var dlo = new DataLoadOptions(); dlo.LoadWith <BillDemandDistribution>(p => p.Demand); dlo.LoadWith <Demand>(p => p.Limit); using (var context = CreateContext()) { context.LoadOptions = dlo; var distributions = GetBillDemandDistributions(instanceId, identity.Id, type, context); if (distributions.Count() == 0) { return(false); } var sightings = GetSightings(instanceId, identity.Id, type, context); if (sightings.Count() == 0) { return(true); } return(!distributions.TrueForAll( p => p.DemandId.HasValue && p.Demand.LimitId.HasValue && sightings.FirstOrDefault(s => s.ItemId == p.Demand.LimitId) != null)); } }
private IQueryable <li_wallet_histories> QueryWalletHistories() { var userId = string.IsNullOrWhiteSpace(user_id) ? 0 : Convert.ToInt32(user_id); var options = new DataLoadOptions(); options.LoadWith <li_wallet_histories>(h => h.li_project_transactions); options.LoadWith <li_wallet_histories>(h => h.li_bank_transactions); options.LoadWith <li_wallet_histories>(h => h.li_activity_transactions); options.LoadWith <li_project_transactions>(tr => tr.li_projects); options.LoadWith <li_project_transactions>(tr => tr.li_claims_from); context.LoadOptions = options; IQueryable <li_wallet_histories> query = context.li_wallet_histories; if (userId != 0) { query = query.Where(h => h.user_id == userId); } if (0 < action_type) { ddlWalletHistoryTypeId.SelectedValue = action_type.ToString(); query = query.Where(h => h.action_type == action_type); } //用户分组查询 if (0 < userGroup) // 选择了某一组 { ddlUserGroud.SelectedValue = userGroup.ToString(); query = query.Where(w => w.dt_users.group_id == userGroup); } else { // 限制当前管理员对会员的查询 var canAccessGroups = context.li_user_group_access_keys.Where(k => k.owner_manager == GetAdminInfo().id).Select(k => k.user_group).ToArray(); query = query.Where(w => !canAccessGroups.Any() || canAccessGroups.Contains(w.dt_users.group_id)); } if (cb_today.Checked) { query = query.Where(h => h.create_time.Date == DateTime.Now.Date); } else { if (!string.IsNullOrWhiteSpace(txtStartTime.Text)) { query = query.Where(h => h.create_time.Date >= Convert.ToDateTime(txtStartTime.Text)); } if (!string.IsNullOrWhiteSpace(txtEndTime.Text)) { query = query.Where(h => h.create_time.Date <= Convert.ToDateTime(txtEndTime.Text)); } } query = query.Where(h => (h.dt_users.real_name.Contains(txtKeywords.Text) || h.dt_users.user_name.Contains(txtKeywords.Text)) || h.dt_users.mobile.Contains(txtKeywords.Text)) .Where(h => userId == 0 ? !_ignoringHistoryTypes.Contains(h.action_type) : !_ignoringHistoryTypesSpecificUser.Contains(h.action_type)); return(query); }
private static DataLoadOptions GetDefaultDataLoadOptions() { var lo = new DataLoadOptions(); lo.LoadWith<Document>(c => c.Employee); lo.LoadWith<Document>(c => c.Employee1); lo.LoadWith<DocumentTransitionHistory>(c=>c.Employee); return lo; }
public static void SetChildLoadOptions(DataLoadOptions loadOptions) { loadOptions.LoadWith <AddressPoint>(ap => ap.AddressPointStatus); loadOptions.LoadWith <AddressPoint>(ap => ap.GeographicPointLocation); AddressPointStatus.SetChildLoadOptions(loadOptions); GeographicPointLocation.SetChildLoadOptions(loadOptions); }
static RecruitersRepository() { OrganisationLoadOptions = new DataLoadOptions(); OrganisationLoadOptions.LoadWith <OrganisationEntity>(o => o.OrganisationalUnitEntity); OrganisationLoadOptions.LoadWith <OrganisationEntity>(o => o.AddressEntity); OrganisationLoadOptions.LoadWith <AddressEntity>(a => a.LocationReferenceEntity); OrganisationLoadOptions.LoadWith <OrganisationalUnitEntity>(o => o.ContactDetailsEntity); }
public static DataLoadOptions CreateLoadOptions <T1, T2>(Expression <Func <T1, object> > loadWith1, Expression <Func <T2, object> > loadWith2) { var options = new DataLoadOptions(); options.LoadWith(loadWith1); options.LoadWith(loadWith2); return(options); }
public SanPhamDAO() { this.context = new SEDataContext(Global.ConnectionString); DataLoadOptions loadOption = new DataLoadOptions(); loadOption.LoadWith <SanPham>(x => x.ChiTietSanPhams); loadOption.LoadWith <SanPham>(x => x.LoaiSP); }
public TaskRepository() { _dataContext = new DataContextDataContext(); DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Task>(t => t.Project); dlo.LoadWith<Task>(t => t.Priority); _dataContext.LoadOptions = dlo; }
private static DataLoadOptions GetDefaultDataLoadOptions() { var lo = new DataLoadOptions(); lo.LoadWith<Employee>(c => c.StructDivision); lo.LoadWith<EmployeeRole>(c => c.Role); lo.LoadWith<Employee>(c => c.EmployeeRoles); return lo; }
public ModelDataContext() : base(Settings.Default.MyBlogConnectionString, xmlSource) { var ds = new DataLoadOptions(); ds.LoadWith<Post>(p => p.Comments); ds.LoadWith<Post>(p => p.CategoryLinks); ds.LoadWith<PostCategoryLink>(o => o.PostCategory); this.LoadOptions = ds; }
/// <summary> /// Quote Manager /// </summary> public QuoteManager() { db = new BizzyQuoteDataContext(Properties.Settings.Default.BizzyQuoteConnectionString); var options = new DataLoadOptions(); options.LoadWith<Quote>(q => q.QuoteItems); options.LoadWith<QuoteItem>(qi => qi.Material); options.LoadWith<QuoteItem>(qi => qi.Product); db.LoadOptions = options; }
public SettingsRepository() { var loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Settings>(s => s.Server); loadOptions.LoadWith<Settings>(s => s.Language); loadOptions.LoadWith<Settings>(s => s.PhotoResolution); _context.LoadOptions = loadOptions; }
public static IEnumerable<Transit> GetTransits(string playerName, string password) { var db = new DbDataContext(); var dl = new DataLoadOptions(); dl.LoadWith<Transit>(x => x.Fleets); dl.LoadWith<Fleet>(x => x.FleetShips); dl.LoadWith<Transit>(x => x.PopulationTransports); dl.LoadWith<Transit>(x => x.Players); db.LoadOptions = dl; return db.Transits.ToList(); }
void AnimationList_Loaded(object sender, RoutedEventArgs e) { grdAnimations.DataContext = animationManager; DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Animation>(a => a.AnimationType); loadOptions.LoadWith<Animation>(a => a.Priority); loadOptions.LoadWith<Animation>(a => a.SalesDrive); DbDataContext.MakeNewInstance(loadOptions); animationManager.AllAnimations = null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int personId = 0; if (Request.QueryString["id"] != null && int.TryParse(TamperProofString.QueryStringDecode(Request.QueryString["id"]), out personId)) { Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString); DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Ajancy.Person>(p => p.DrivingLicenses); dlo.LoadWith<Ajancy.Person>(p => p.DriverCertifications); dlo.LoadWith<Ajancy.DriverCertification>(dc => dc.DriverCertificationCars); dlo.LoadWith<Ajancy.DriverCertificationCar>(dcc => dcc.CarPlateNumber); dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.PlateNumber); dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.Car); dlo.LoadWith<Ajancy.Car>(c => c.FuelCards); dlo.LoadWith<Ajancy.Car>(c => c.CarType); db.LoadOptions = dlo; SetPerson(db.Persons.FirstOrDefault<Ajancy.Person>(p => p.PersonID == personId)); db.Dispose(); } else { Response.Redirect("~/Default.aspx"); } } }
protected void Page_PreRender( object sender, EventArgs e ) { using(var dc = new DCFactory<CmsDataContext>()) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Shop>(s => s.ShopMapFile); dlo.LoadWith<Shop>(s => s.ShopGalleryFolder); dlo.LoadWith<Folder>(f => f.Files); dc.DataContext.LoadOptions = dlo; dc.DataContext.DeferredLoadingEnabled = true; _item = dc.DataContext.Shops.Where(s => s.ShopID == ShopId && s.ShopVisible).SingleOrDefault(); if( _item == null ) throw new HttpException((int)HttpStatusCode.NotFound, "Not found" ); _shopVacancyBriefList1.ShopID = _item.ShopID; if( _item.ShopMapFile != null ) { _mapLink.Visible = true; _mapLink.NavigateUrl = UrlManager.GetFileUrl( _item.ShopMapFile.FileID ); _mapLink.Attributes[ "onclick" ] = string.Format( "info=window.open(this.href,'','width={0},height={1},scrollbars=yes,resizable=yes'); info.focus(); return false;", _item.ShopMapFile.ImageWidth.Value + 40, _item.ShopMapFile.ImageHeight.Value + 30 ); _mapImage.ImageUrl = UrlManager.GetThumbnailUrl( _item.ShopMapFile.FileID, "map", "" ); } else { _mapLink.Visible = false; } if( _item.ShopGalleryFolder != null && _item.ShopGalleryFolder.Files.Count != 0 ) { _galleryRow.Visible = true; List<File> AllPhotos = _item.ShopGalleryFolder.Files.Where(f => f.IsImage == true).ToList(); var firstPhoto = AllPhotos.Take(1); GalleryHeader.DataSource = firstPhoto; GalleryHeader.DataBind(); _galleryRepeater.DataSource = AllPhotos.Except(firstPhoto); _galleryRepeater.DataBind(); } else { _galleryRow.Visible = false; } } lVacancy.Visible = _shopVacancyBriefList1.Count > 0; }
public IEnumerable<User> GetAllUser() { using (UserDataContext dataContext = new UserDataContext()) { DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Link>(l => l.Uploads); loadOptions.LoadWith<User>(u=>u.Links); dataContext.LoadOptions = loadOptions; IEnumerable<User> Users = dataContext.Users.ToList(); return Users; } }
public Session GetByUniqueUrl(string sessionUrl) { using (var context = new TrianglesDataContext()) { var options = new DataLoadOptions(); options.LoadWith<Session>(s => s.Expenditures); options.LoadWith<Session>(s => s.Receipts); options.LoadWith<Receipt>(r => r.ReceiptRecords); context.LoadOptions = options; var session = context.Sessions.FirstOrDefault(x => x.UniqueUrl == sessionUrl); return session; } }
void MainPage_Loaded(object sender, RoutedEventArgs e) { using (CalendarClassEntitiesDataContext dc = new CalendarClassEntitiesDataContext(App.conexionString)) { App.Context.ListaMateria.Clear(); DataLoadOptions dl = new DataLoadOptions(); dl.LoadWith<Materia>(p => p.Recurso); dl.LoadWith<Materia>(p => p.Actividads); dc.LoadOptions = dl; (from m in dc.Materias select m).ToList().ForEach(p => App.Context.ListaMateria.Add(p)); } }
public IEnumerable<Link> GetAllLinks() { using (UserDataContext dataContext = new UserDataContext()) { DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Link>(l => l.Uploads); loadOptions.LoadWith<Link>(l=>l.User); dataContext.LoadOptions = loadOptions; IEnumerable<Link> Links = dataContext.Links.ToList(); return Links; } }
public void ExecuteQueryLoadWith() { var db = new TrackerDataContext { Log = Console.Out }; db.DeferredLoadingEnabled = false; db.ObjectTrackingEnabled = false; DataLoadOptions options = new DataLoadOptions(); options.LoadWith<Task>(t => t.CreatedUser); db.LoadOptions = options; var q1 = db.User .ByEmailAddress("*****@*****.**"); var q2 = db.Task .Where(t => t.LastModifiedBy == "*****@*****.**"); var result = db.ExecuteQuery(q1, q2); Assert.IsNotNull(result); var userResult = result.GetResult<User>(); Assert.IsNotNull(userResult); var users = userResult.ToList(); Assert.IsNotNull(users); var taskResult = result.GetResult<Task>(); Assert.IsNotNull(taskResult); var tasks = taskResult.ToList(); Assert.IsNotNull(tasks); }
internal Materia GetMateriaById(int materiaId) { using (CalendarClassEntitiesDataContext dc = new CalendarClassEntitiesDataContext(App.conexionString)) { DataLoadOptions dl = new DataLoadOptions(); dl.LoadWith<Materia>(p => p.Recurso); dl.LoadWith<Materia>(p => p.Actividads); dc.LoadOptions = dl; var query = from m in dc.Materias where m.MateriaId == materiaId select m; return query.SingleOrDefault(); } }
private IEnumerable GetServerData(GridCommand command) { DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Order>(o => o.Customer); var dataContext = new NorthwindDataContext { LoadOptions = loadOptions }; IQueryable<Order> data = dataContext.Orders; //Apply filtering data = data.ApplyFiltering(command.FilterDescriptors); ViewData["Total"] = data.Count(); //Apply sorting data = data.ApplySorting(command.GroupDescriptors, command.SortDescriptors); //Apply paging data = data.ApplyPaging(command.Page, command.PageSize); //Apply grouping if (command.GroupDescriptors.Any()) { return data.ApplyGrouping(command.GroupDescriptors); } return data.ToList(); }
/// <summary> /// User Manager /// </summary> public UserManager() { db = new BizzyQuoteDataContext(Properties.Settings.Default.BizzyQuoteConnectionString); var options = new DataLoadOptions(); options.LoadWith<User>(u => u.Company); db.LoadOptions = options; }
// // GET: /Document/Details/5 public ActionResult Details(int id) { DocumentViewModel model = new DocumentViewModel(); using (var db = new DocumentDataContext()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<Document>(d => d.User); options.LoadWith<Document>(d => d.Comments); options.LoadWith<Comment>(d => d.User); options.LoadWith<Document>(d => d.CategoryDocuments); options.LoadWith<CategoryDocument>(d => d.Category); db.LoadOptions = options; model.CurrentDocument = db.getDocument(id); } return View(model); }
partial void OnCreated() { DataLoadOptions opts = new DataLoadOptions(); opts.LoadWith<Room>(r => r.Computers); LoadOptions = opts; }
/// <summary> /// Update profile /// </summary> protected void btnSubmit_Click(object sender, EventArgs e) { using (var context = new PetShopDataContext()) { var options = new DataLoadOptions(); options.LoadWith<Profile>(p => p.AccountList); context.LoadOptions = options; var profile = context.Profile.GetProfile(User.Identity.Name); if (!string.IsNullOrEmpty(profile.Username) && AddressForm.IsValid) { if (profile.AccountList.Count > 0) { Account account = profile.AccountList[0]; UpdateAccount(ref account, AddressForm.Address); } else { var account = new Account(); profile.AccountList.Add(account); account.UniqueID = profile.UniqueID; UpdateAccount(ref account, AddressForm.Address); } context.SubmitChanges(); } } lblMessage.Text = "Your profile information has been successfully updated.<br> "; }
public void Save(params ContentType[] contentTypes) { using (var ts = new TransactionScope()) using (var dataContext = new ContentDataContext(connectionString)) { var loadOptions = new DataLoadOptions(); loadOptions.LoadWith<ContentTypeItem>(ct => ct.ContentActionItems); dataContext.LoadOptions = loadOptions; var contentTypeItems = dataContext.ContentTypeItems.ToList(); var itemsToDelete = from data in contentTypeItems where !contentTypes.Any(t => t.Type == data.Type && t.ControllerName == data.ControllerName) select data; var itemsToUpdate = (from data in contentTypeItems let type = contentTypes.SingleOrDefault(t => t.Type == data.Type && t.ControllerName == data.ControllerName) where type != null select new { data, type }).ToList(); var itemsToInsert = (from type in contentTypes where !contentTypeItems.Any(t => t.Type == type.Type && t.ControllerName == type.ControllerName) select CreateContentTypeItem(type)).ToList(); itemsToUpdate.ForEach(i => UpdateContentTypeItem(i.data, i.type, dataContext)); dataContext.ContentTypeItems.DeleteAllOnSubmit(itemsToDelete); dataContext.ContentTypeItems.InsertAllOnSubmit(itemsToInsert); dataContext.SubmitChanges(); ts.Complete(); } }
public IEnumerable<Link> GetLinkbyUsers(string userName) { using (UserDataContext dataContext = new UserDataContext()) { DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Link>(l => l.Uploads); loadOptions.LoadWith<Link>(l => l.User); dataContext.LoadOptions = loadOptions; User u = dataContext.Users.FirstOrDefault(user => user.UserName == userName); IEnumerable<Link> linksByUser = dataContext.Links.Where(l => l.Id == u.Id).ToList(); return linksByUser; } }
public Repository(string strConnection) { m_ctx = new DataContext(strConnection); DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Artist>(c => c.Genre); m_ctx.LoadOptions = dlo; }
public ActionResult RemoveRole(int userId, int roleId) { using (var db = new TrackerDataContext()) { var options = new DataLoadOptions(); options.LoadWith<User>(u => u.UserRoleList); options.LoadWith<UserRole>(r => r.Role); db.LoadOptions = options; var user = db.User.GetByKey(userId); var role = user.RoleList.FirstOrDefault(r => r.Id == roleId); user.RoleList.Remove(role); db.SubmitChanges(); } return RedirectToAction("Edit", new { id = userId }); }