查询条件TPH inheritance 查询的 3 种写法

废话就不多说了,开始。。。

    TPHinheritance 查询的 3 种写法

    var USACustomers1 = from c inNWEntities.BaseCustomers

                        where c is USACustomer

                        select c;

    var USACustomers2 = from c inNWEntities.BaseCustomers.OfType<USACustomer>()

                        select c;

    每日一道理
最为值得珍惜的是今天,因为最容易流逝的就是今天,把握今天就是把握希望,分分秒秒只是瞬间,而所乘载的分分秒秒就叫做一天,时间的流逝往往是在不经意之间,人生几回,青春更珍贵,对于我们这个年龄的青少年来说,青春已不足二十载,在学习的生活中我们必须靠自己的力量,驾驭着自己的小船驶向希望的彼岸。

    var USACustomers3 = from c inNWEntities.BaseCustomers

                        select c as USACustomer;

    Console.WriteLine("Total number of USAcustomers (is): {0}", USACustomers1.Count());

    Console.WriteLine("Total number of USAcustomers (ofType): {0}", USACustomers2.Count());

    Console.WriteLine("Total number of USAcustomers (as): {0}", USACustomers3.Count(i => i != null));

     

    第三种写法必须加上I <> null 的条件。

文章结束给大家分享下程序员的一些笑话语录: 祝大家在以后的日子里. 男生象Oracle般健壮; 女生象win7般漂亮; 桃花运象IE中毒般频繁; 钱包如Gmail容量般壮大, 升职速度赶上微软打补丁 , 追女朋友像木马一样猖獗, 生活像重装电脑后一样幸福, 写程序敲代码和聊天一样有**。

原文地址:https://www.cnblogs.com/xinyuyuanm/p/3045525.html