网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

【C#】ADO.NetEntitiesFramework在WPFTreeView中的应用

XAML代码

成都创新互联专业为企业提供大英网站建设、大英做网站、大英网站设计、大英网站制作等企业网站建设、网页设计与制作、大英企业网站模板建站服务,10年大英做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:WpfApplication73"

        mc:Ignorable="d"

        Title="MainWindow" Height="350" Width="525">

   

       

           

               

                 

                       

                  

               

                

               

                   

                       

                       

                   

               

               

                   

                       

                       

                   

               

           

       

   

隐藏代码:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

namespace WpfApplication73

{

    ///

    /// Interaction logic for MainWindow.xaml

    ///

    public partial class MainWindow : Window

    {

        public Formula1v2Entities data = new Formula1v2Entities();

        public MainWindow()

        {

            InitializeComponent();

            this.DataContext = Years;

        }

        public IEnumerable Years

        {

            get

            {

                F1DataContext.Data = data;

                return data.Races.Select(r => new Class1

                {

                    Year = r.Date.Year

                }).Distinct().OrderBy(c => c.Year).ToList();

                //return (from r in data.Races

                //        select new Class1

                //        {

                //           Year= r.Date.Year

                //        }).ToList();

            }

        }

    }

}

Class1代码,用来产生TreeView控件使用的集合

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace WpfApplication73

{

    public static class F1DataContext

    {

        public static Formula1v2Entities Data { get; set; }

    }

  public class Class1

    {       

        public int Year { get; set; }

        public IEnumerableRaces

        {

            get

            {

                

                   return (from r in F1DataContext.Data.Races

                           where r.Date.Year == Year

                           orderby r.Date

                           select new F1Race

                           {

                               Date = r.Date,

                               Country = r.Circuits.Country

                           }).ToList();

            

                

            }

        }

       

        }

   public class F1Race

    {

        public string Country { get; set; }

        public DateTime Date { get; set; }

        public IEnumerable Results

        {

            get

            {

                return (from rr in F1DataContext.Data.RaceResults

                        where rr.Races.Date == this.Date

                        select new F1RaceResult

                        {

                            Position = rr.Position,

                            Racer = rr.Racers.FirstName + " " + rr.Racers.LastName

                        }).ToList();

            }

        }

       

    }

   public class F1RaceResult

    {

        public int Position { get; set; }

        public string Racer { get; set; }

    }

}


分享标题:【C#】ADO.NetEntitiesFramework在WPFTreeView中的应用
浏览路径:http://bjjierui.cn/article/poosch.html

其他资讯