当前位置: 首页>>代码示例>>C#>>正文


C# DataLoadOptions.AssociateWith方法代码示例

本文整理汇总了C#中DataLoadOptions.AssociateWith方法的典型用法代码示例。如果您正苦于以下问题:C# DataLoadOptions.AssociateWith方法的具体用法?C# DataLoadOptions.AssociateWith怎么用?C# DataLoadOptions.AssociateWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataLoadOptions的用法示例。


在下文中一共展示了DataLoadOptions.AssociateWith方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            NorthwindDataContext context = new NorthwindDataContext();
            //var result = from item in context.Categories
            //             where item.CategoryID == 48090
            //             select item;
            var result = context.SelectCategory(48090);
            foreach (var item in result)
            {
                Console.WriteLine("{0} {1}", item.CategoryID, item.CategoryName);
            }

            //context.DeferredLoadingEnabled = false;
            var ldOptions = new DataLoadOptions();
            ldOptions.AssociateWith<Category>((c) => (c.Products));
            context.LoadOptions = ldOptions;
            context.ObjectTrackingEnabled = false; // turns DeferredLoadingEnabled to false
            var result1 = context.Categories.Where((prod) => (prod.CategoryID == 65985)).Single();
            foreach (var item in result1.Products)
            {
                Console.WriteLine("{0} {1}",item.ProductID, item.ProductName);
            }

            Console.WriteLine();
            Compile();
            //Query2();
            //DirectExe();
            //Modify();
            //Trans();
            //MyDel();
            //Track();
            CreateDB();
            Console.ReadLine();
        }
开发者ID:naynishchaughule,项目名称:CSharp,代码行数:34,代码来源:Program.cs

示例2: DataBaseViewModel

        public DataBaseViewModel(string connectionString)
        {
            dataBase = new DataBaseContext(connectionString);

            DataLoadOptions loadOptions = new DataLoadOptions();
            loadOptions.AssociateWith<Dictionary>(x => x.Words.OrderBy(y => y.Original));
            dataBase.LoadOptions = loadOptions;

            LoadLanguages();
            if (Languages.Count == 0)
            {
                AddLanguages(new Language[] {
                        new Language() { Code = "en", Name = "English" },
                        new Language() { Code = "ru", Name = "Русский" },
                        new Language() { Code = "lv", Name = "Latviešu" }
                    });
            }
        }
开发者ID:jeremejevs,项目名称:word-steps,代码行数:18,代码来源:DataBaseViewModel.cs

示例3: MeetingsViewerForm_Load

        /// <summary>
        /// Handles the Load event of the MeetingsViewerForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void MeetingsViewerForm_Load(object sender, EventArgs e)
        {
            MeetingDataContext mdc = new MeetingDataContext(
                ConfigurationManager.ConnectionStrings["hamwicConnectionString"].ConnectionString);

            DataLoadOptions dlo = new DataLoadOptions();
            dlo.LoadWith<Subgroup>(s => s.Name);
            dlo.AssociateWith<Subgroup>(s => s.Name);
            mdc.LoadOptions = dlo;

            var meetings = from m in mdc.Meetings
                           from s in mdc.Subgroups
                           select new
                           {
                               m.Id,
                               m.Location_,
                               s.Name,
                               m.DateTimeFrom,
                               m.DateTimeTo
                           };
            SetupDataGridView(meetings);
        }
开发者ID:adamongit,项目名称:Housing-co-op-app,代码行数:27,代码来源:MeetingsViewerForm.cs

示例4: LinqToSqlObject04

        public void LinqToSqlObject04() {

            Northwind db2 = new Northwind(connString);
            db2.Log = this.OutputStreamWriter;

            DataLoadOptions ds = new DataLoadOptions();
            ds.LoadWith<Customer>(p => p.Orders);
            ds.LoadWith<Order>(p => p.OrderDetails);
            ds.AssociateWith<Order>(p=>p.OrderDetails.OrderBy(o=>o.Quantity));

            db2.LoadOptions = ds;
         
            var custs = (
                from c in db2.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 Quantity {3}.",
                            cust.CustomerID, ord.OrderID, orderDetail.ProductID, orderDetail.Quantity );
                    }
                }
            }
        }
开发者ID:FabioOstlind,项目名称:TestRepo,代码行数:26,代码来源:LinqToSqlSamples.cs

示例5: LinqToSqlObject03

        public void LinqToSqlObject03() {

            Northwind db2 = new Northwind(connString);
            db2.Log = this.OutputStreamWriter;

            DataLoadOptions ds = new DataLoadOptions();
            ds.AssociateWith<nwind.Customer>(p => p.Orders.Where(o=>o.ShipVia > 1));

            db2.LoadOptions = ds;
            var custs =
                from c in db2.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} that ShipVia is {2} with ProductID {3} that has name {4}.",
                            cust.CustomerID, ord.OrderID, ord.ShipVia, orderDetail.ProductID, orderDetail.Product.ProductName);
                    }
                }
            }
        }
开发者ID:FabioOstlind,项目名称:TestRepo,代码行数:23,代码来源:LinqToSqlSamples.cs

示例6: ReadFromDatabase

        static Database ReadFromDatabase(this NorthwindDataContext ctx, string path) {
            Database db = new Database();
        
            DataLoadOptions opt = new DataLoadOptions();
            opt.AssociateWith<Order>(order => order.Lines);
            ctx.LoadOptions = opt;
            db.Orders.AddRange(ctx.Orders);

            using (FileStream fs = File.Create(path))
            {
                Serializer.Serialize(fs, db);
            }
            return db;            
        }
开发者ID:GeorchW,项目名称:protobuf-net,代码行数:14,代码来源:Program.cs

示例7: OnCreated

        /// <summary>
        /// Called when this instance is created.
        /// </summary>
partial         void OnCreated()
        {
            var loadOptions = new DataLoadOptions();
            loadOptions.AssociateWith<Survey>(survey => survey.Sections.OrderBy(section => section.RelativeOrder));
            loadOptions.AssociateWith<Section>(section => section.Questions.OrderBy(question => question.RelativeOrder));
            loadOptions.AssociateWith<Question>(question => question.Answers.OrderBy(answer => answer.RelativeOrder));
            this.LoadOptions = loadOptions;
        }
开发者ID:krishna23456,项目名称:Engage-Survey,代码行数:11,代码来源:SurveyModelDataContext.cs

示例8: GetCatalogItem2DataLoadOptions

 //private static DataLoadOptions _getCatalogItem2Dlo = GetCatalogItem2DataLoadOptions();
 private static DataLoadOptions GetCatalogItem2DataLoadOptions(string locale)
 {
     var res = new DataLoadOptions();
     res.LoadWith<SeoPartsCatalogItem>( c => c.NameRU );
     res.LoadWith<SeoPartsCatalogItem>( c => c.BodyRU );
     res.LoadWith<SeoPartsCatalogItem>( c => c.PageDescriptionRU );
     res.LoadWith<SeoPartsCatalogItem>( c => c.PageKeywordsRU );
     res.LoadWith<SeoPartsCatalogItem>( c => c.PageFooterRU );
     if (locale != "ru-RU")
     {
         res.LoadWith<SeoPartsCatalogItem>( c => c.SeoPartsCatalogItemsLocs );
         res.AssociateWith<SeoPartsCatalogItem>( c => c.SeoPartsCatalogItemsLocs.Where(i => i.Localization == locale) );
     }
     return res;
 }
开发者ID:dmziryanov,项目名称:ApecAuto,代码行数:16,代码来源:SeoPartsCatalogDac.cs

示例9: Init

        /// <summary>Initializes all data for a zone - spawns, zone points, AA, etc.</summary>
        private bool Init(ushort zoneId, ZoneInstanceType ziType)
        {
            // Load the zone along with associated zone points, spawns, spawn groups, spawn group entries and NPCs.
            // TODO: Probably will want to load this differently when zone state persistance is in (join to a state table for spawns?)
            DataLoadOptions dlo = new DataLoadOptions();
            dlo.LoadWith<Zone>(z => z.ZonePoints);
            dlo.LoadWith<Zone>(z => z.Doors);
            dlo.LoadWith<Zone>(z => z.Spawns);
            dlo.LoadWith<Internals.Data.Spawn>(s => s.SpawnGroup);
            dlo.LoadWith<SpawnGroup>(sg => sg.SpawnGroupEntries);
            dlo.AssociateWith<SpawnGroup>(sg => sg.SpawnGroupEntries.OrderBy(sge => sge.Chance));   // sort the spawnGroupEntries by chance
            dlo.LoadWith<SpawnGroupEntry>(sge => sge.Npc);
            dlo.LoadWith<Npc>(npc => npc.Loot);
            dlo.LoadWith<Loot>(l => l.LootEntries);
            dlo.LoadWith<LootEntry>(le => le.LootDrops);
            dlo.LoadWith<LootDrop>(ld => ld.Item);  // TODO: can we trim how much of an item comes back?

            using (EmuDataContext dbCtx = new EmuDataContext())
            {
                dbCtx.ObjectTrackingEnabled = false;    // only loading referential data
                dbCtx.LoadOptions = dlo;    // TODO: use profiler to make sure we get it all in one call
                //dbCtx.Log = new Log4NetWriter(typeof(ZoneServer));
                _zone = dbCtx.Zones.Single(z => z.ZoneID == zoneId);
            }

            this.Zone.InitNewZoneStruct();
            _instanceType = ziType;

            // Load map & water map
            _map = new Map();
            _waterMap = new WaterMap();
            try
            {
                if (!_map.LoadMapFromFile(_zone.ShortName))
                    return false;

                if (!_waterMap.LoadMapFromFile(_zone.ShortName))
                    _waterMap = null;
            }
            catch (Exception e)
            {
                _log.Error("Error during map loading", e);
            }

            _mobMgr.Init();     // Must be done prior to any doors, mobs or player init

            if (_zone.Doors.Count > 0)
            {
                foreach (Door d in _zone.Doors)
                    d.EntityId = GetNewEntityId();  // Assign each door an entity Id

                _log.InfoFormat("Loaded {0} doors", _zone.Doors.Count);
            }
            else
                _log.Warn("No doors loaded");

            // TODO: Load Spawn Conditions

            SpawnTimerCallback(null);   // Load spawns NOW
            _log.InfoFormat("Loaded {0} Spawn", _mobMgr.MobCount);

            // TODO: Implement zone state persistance

            // TODO: Load corpses

            // TODO: Load traps

            // TODO: Load ground spawns

            // TODO: Load objects (tradeskill containers, maybe books, etc.)

            _maxSpellId = WorldSvc.GetMaxSpellId();
            if (_maxSpellId == 0)
                _log.Error("Max SpellId equals zero.  Problem with spell loading in world?");

            // TODO: Load blocked spells

            // TODO: Load guilds, factions, titles, AA, Tributes, corpse timers?

            // TODO: Load merchant data

            // TODO: Load petition data

            // TODO: Load graveyard

            // TODO: Load timezone data

            // TODO: Implement server time keeping in world and then sync up here (see end of orig Init and bootup routines)

            // Just before we finish, start up the various timers
            _spawnTimer.Change(30000, SPAWN_TIMER_INTERVAL);    // We've already populated the spawn list, so wait a bit
            _spawnQueueTimer.Change(5000, SPAWN_QUEUE_TIMER_INTERVAL);  // wait 5 sec before worrying about queued spawn packets
            _doorTimer.Change(10000, DOOR_TIMER_INTERVAL);  // wait 10 sec before worrying about doors

            // Initialize weather timer
            if (_zone.Weather <= 3 && _zone.Weather > 0)
            {
                Random rand = new Random();
                _weatherTimer.Change(0, (rand.Next(1800, 7200) + 30) * 2000);
//.........这里部分代码省略.........
开发者ID:natedahl32,项目名称:EqEmulator-net,代码行数:101,代码来源:ZoneServer.cs

示例10: LoadOrderLineData

        public static OrderLine LoadOrderLineData(string clientId, int orderLineId, bool TrackEnable)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {

                DataLoadOptions options = new DataLoadOptions();
                options.LoadWith<OrderLine>(l => l.Order);
                options.LoadWith<OrderLine>(l => l.OrderLineStatusChanges);
                options.AssociateWith<OrderLine>(l => l.OrderLineStatusChanges.OrderBy(sc => sc.StatusChangeTime));
                dc.DataContext.LoadOptions = options;

                dc.DataContext.DeferredLoadingEnabled = false;
                dc.DataContext.ObjectTrackingEnabled = TrackEnable;

                var OrdLn = dc.DataContext.OrderLines.Where(l =>
                    l.OrderLineID == orderLineId &&
                    l.Order.ClientID == clientId).ToArray()[0];

                if (!TrackEnable)
                {
                    OrderLine res2 = new OrderLine();
                    Order o = new Order();
                    OrderLine res = Serializer.JsonClone<OrderLine>(OrdLn, res2);
                    res.Order = Serializer.JsonClone<Order>(OrdLn.Order, o);
                    return res;
                }
                else
                    return OrdLn;
                //return res;
            }
        }
开发者ID:dmziryanov,项目名称:ApecAuto,代码行数:31,代码来源:OrderBO.cs

示例11: LoadOrderData

        public static Order LoadOrderData(string clientId, int orderId)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {
                DataLoadOptions options = new DataLoadOptions();
                options.LoadWith<Order>(o => o.OrderLines);
                options.LoadWith<OrderLine>(l => l.OrderLineStatusChanges);
                options.AssociateWith<OrderLine>(l => l.OrderLineStatusChanges.OrderBy(sc => sc.StatusChangeTime));
                dc.DataContext.LoadOptions = options;

                dc.DataContext.DeferredLoadingEnabled = false;

                Order res;

                if (SiteContext.Current.User.Role == SecurityRole.Manager && AcctgRefCatalog.RmsFranches[SiteContext.Current.InternalFranchName].isLite)
                {
                    res = dc.DataContext.Orders.Single(o =>
                        o.OrderID == orderId);
                }
                else
                {
                    res = dc.DataContext.Orders.Single(o =>
                        o.OrderID == orderId &&
                        o.ClientID == clientId);
                }

                foreach (var l in res.OrderLines)
                {
                    var parent = l.ParentOrderLine;
                }
                return res;
            }
        }
开发者ID:dmziryanov,项目名称:ApecAuto,代码行数:33,代码来源:OrderBO.cs


注:本文中的DataLoadOptions.AssociateWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。