• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ArubaModel.ArubaContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Entity.TestModels.ArubaModel.ArubaContext的典型用法代码示例。如果您正苦于以下问题:C# ArubaContext类的具体用法?C# ArubaContext怎么用?C# ArubaContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArubaContext类属于System.Data.Entity.TestModels.ArubaModel命名空间,在下文中一共展示了ArubaContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SelectMany_with_DefaultIfEmpty_translates_into_left_outer_join

        public void SelectMany_with_DefaultIfEmpty_translates_into_left_outer_join()
        {
            using (var context = new ArubaContext())
            {
                var expectedSql =
@"SELECT 
[Extent1].[Id] AS [Id], 
[Extent2].[Id] AS [Id1], 
[Extent2].[Name] AS [Name], 
[Extent2].[Deleted] AS [Deleted], 
[Extent2].[TaskInfo_Passed] AS [TaskInfo_Passed], 
[Extent2].[TaskInfo_Failed] AS [TaskInfo_Failed], 
[Extent2].[TaskInfo_Investigates] AS [TaskInfo_Investigates], 
[Extent2].[TaskInfo_Improvements] AS [TaskInfo_Improvements], 
[Extent2].[ArubaRun_Id] AS [ArubaRun_Id]
FROM  [dbo].[ArubaRuns] AS [Extent1]
LEFT OUTER JOIN [dbo].[ArubaTasks] AS [Extent2] ON [Extent1].[Id] = [Extent2].[ArubaRun_Id]";

                var query = context.Runs.SelectMany(c => c.Tasks.DefaultIfEmpty());
                QueryTestHelpers.VerifyDbQuery(query, expectedSql);

                // verify that owners that have empty collecion of bugs are projected as nulls
                var results = query.ToList();
                var ownersWithoutBugsCount = context.Runs.Count(o => !o.Tasks.Any());
                Assert.Equal(ownersWithoutBugsCount, results.Count(r => r == null));
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:27,代码来源:DefaultIfEmptyTests.cs


示例2: DefaultIfEmpty_with_non_null_default

        public void DefaultIfEmpty_with_non_null_default()
        {
            using (var context = new ArubaContext())
            {
                var expectedSql =
@"SELECT 
[Extent1].[Id] AS [Id], 
[Extent1].[FirstName] AS [FirstName], 
[Extent1].[LastName] AS [LastName], 
[Extent1].[Alias] AS [Alias], 
CASE WHEN ([Join1].[Id1] IS NULL) THEN 0 ELSE [Join1].[Id1] END AS [C1]
FROM  [dbo].[ArubaOwners] AS [Extent1]
LEFT OUTER JOIN  (SELECT [Extent2].[Id] AS [Id1], [Extent2].[ArubaOwner_Id] AS [ArubaOwner_Id]
	FROM  [dbo].[Bugs1] AS [Extent2]
	INNER JOIN [dbo].[Bugs2] AS [Extent3] ON [Extent2].[Id] = [Extent3].[Id] ) AS [Join1] ON ([Extent1].[Id] = [Join1].[ArubaOwner_Id]) AND (1 = [Join1].[Id1])";

                var query = context.Owners.SelectMany(c => c.Bugs.Where(b => b.Id == 1).Select(b => b.Id).DefaultIfEmpty(), (o, b) => new { o, b });
                QueryTestHelpers.VerifyDbQuery(query, expectedSql);

                // verify that all owners are projected
                // verify that the only bug that is non 0 has Id = 1
                var results = query.ToList();
                var ownersCount = context.Owners.Count();
                Assert.Equal(ownersCount, results.Select(r => r.o.Id).Distinct().Count());
                for (int i = 0; i < ownersCount; i++)
                {
                    var bugId = results[i].b;
                    Assert.True(bugId == 0 || bugId == 1);
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:31,代码来源:DefaultIfEmptyTests.cs


示例3: GeometryPointsWithinPolygon

        public void GeometryPointsWithinPolygon()
        {
            var query = @"
select value 
    g.c32_geometry
from 
    ArubaContext.AllTypes as g
where 
    Edm.SpatialWithin(
        g.c32_geometry,
        GeometryFromText(""MULTILINESTRING ((10 20, 15 20, 15 25, 10 25, 10 20), (12 22, 13 22, 13 23, 12 23, 12 22))"", 32768))";

            // verifying that the points returned are within the specified polygon
            using (var db = new ArubaContext())
            using (var reader = QueryTestHelpers.EntityCommandSetup(db, query, "STWithin"))
            {
                var shape = DbGeometry.MultiLineFromText(
                        "MULTILINESTRING ((10 20, 15 20, 15 25, 10 25, 10 20), (12 22, 13 22, 13 23, 12 23, 12 22))", 32768);
                VerifyValueCondition(reader, o =>
                    {
                        var g = (DbGeometry)o;
                        return DbSpatialServices.Default.Within(g, shape);
                    });
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:SpatialTests.cs


示例4: TruncationTests

 public TruncationTests()
 {
     using (var context = new ArubaContext())
     {
         context.Database.Initialize(force: false);
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:TruncationTests.cs


示例5: String_StartsWith_properly_translated_to_function

 public void String_StartsWith_properly_translated_to_function()
 {
     using (var context = new ArubaContext())
     {
         var query = context.Owners.Select(o => o.LastName.StartsWith("Name"));
         Assert.Contains("LIKE N'NAME%'", query.ToString().ToUpperInvariant());
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:FunctionsTests.cs


示例6: DateTime_UtcNow_properly_translated_to_function

 public void DateTime_UtcNow_properly_translated_to_function()
 {
     using (var context = new ArubaContext())
     {
         var query = context.Owners.Select(o => DateTime.UtcNow);
         Assert.Contains("SYSUTCDATETIME", query.ToString().ToUpperInvariant());
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:FunctionsTests.cs


示例7: String_Length_properly_translated_to_function

 public void String_Length_properly_translated_to_function()
 {
     using (var context = new ArubaContext())
     {
         var query = context.Owners.Select(o => o.LastName.Length);
         Assert.Contains("LEN", query.ToString().ToUpperInvariant());
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:FunctionsTests.cs


示例8: String_Concat_translated_properly_to_plus_operator

 public void String_Concat_translated_properly_to_plus_operator()
 {
     using (var context = new ArubaContext())
     {
         var query = context.Owners.Select(o => string.Concat(o.LastName, o.FirstName));
         Assert.True(query.ToString().Contains("+"));
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:FunctionsTests.cs


示例9: DateTimeOffest_Day_properly_translated_to_function

 public void DateTimeOffest_Day_properly_translated_to_function()
 {
     using (var context = new ArubaContext())
     {
         var query = context.AllTypes.Select(a => a.c30_datetimeoffset.Day);
         Assert.Contains("DATEPART", query.ToString().ToUpperInvariant());
         Assert.Contains("DAY", query.ToString().ToUpperInvariant());
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:FunctionsTests.cs


示例10: Include_one_to_one_relationship

 public void Include_one_to_one_relationship()
 {
     using (var context = new ArubaContext())
     {
         ((IObjectContextAdapter)context).ObjectContext.ContextOptions.LazyLoadingEnabled = false;
         var query = context.Owners.Include(o => o.OwnedRun);
         var results = query.ToList();
         var runsForOwners = context.Owners.Select(r => r.OwnedRun).ToList();
         Enumerable.SequenceEqual(runsForOwners, results.Select(r => r.OwnedRun)); 
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:IncludeTests.cs


示例11: IndexOf_properly_translated_to_function

            public void IndexOf_properly_translated_to_function()
            {
                using (var context = new ArubaContext())
                {
                    var query = context.Owners.Select(o => o.LastName.IndexOf("N"));

                    // translated to charindex() - 1
                    Assert.True(query.ToString().ToLowerInvariant().Contains("charindex"));
                    Assert.Contains("CHARINDEX", query.ToString().ToUpperInvariant());
                    Assert.True(query.ToString().Contains("- 1"));
                }
            }
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:FunctionsTests.cs


示例12: IsNullOrEmpty_translated_properly_to_expression

            public void IsNullOrEmpty_translated_properly_to_expression()
            {
                using (var context = new ArubaContext())
                {
                    var expectedSql =
@"SELECT 
    CASE WHEN (([Extent1].[LastName] IS NULL) OR (( CAST(LEN([Extent1].[LastName]) AS int)) = 0)) THEN cast(1 as bit) WHEN ( NOT (([Extent1].[LastName] IS NULL) OR (( CAST(LEN([Extent1].[LastName]) AS int)) = 0))) THEN cast(0 as bit) END AS [C1]
    FROM [dbo].[ArubaOwners] AS [Extent1]";

                    var query = context.Owners.Select(o => string.IsNullOrEmpty(o.LastName));
                    QueryTestHelpers.VerifyDbQuery(query, expectedSql);
                }
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:FunctionsTests.cs


示例13: Can_materialize_null_complex_type

 public void Can_materialize_null_complex_type()
 {
     using (var context = new ArubaContext())
     {
         var query = context.Runs.Select(r => r.Tasks.Where(t => t.Id < 0).Select(t => t.TaskInfo).FirstOrDefault());
         var results = query.ToList();
         Assert.IsType<List<ArubaTaskInfo>>(results);
         foreach (var result in results)
         {
             Assert.Null(result);
         }
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:MaterializationTests.cs


示例14: OrderBy_ThenBy_lifted_above_type_filter

        public void OrderBy_ThenBy_lifted_above_type_filter()
        {
            using (var context = new ArubaContext())
            {
                var query = context.Configs.OrderByDescending(p => p.Arch).ThenBy(p => p.Id).OfType<ArubaMachineConfig>();
                var baseline = context.Configs.OfType<ArubaMachineConfig>().OrderByDescending(p => p.Arch).ThenBy(p => p.Id);
                Assert.Equal(baseline.ToString(), query.ToString());

                var results = query.ToList();
                var expected = context.Configs.ToList().OrderByDescending(p => p.Arch).ThenBy(p => p.Id).OfType<ArubaMachineConfig>().ToList();
                QueryTestHelpers.VerifyQueryResult(expected, results, (o, i) => o.Id == i.Id);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:13,代码来源:OrderByLiftingTests.cs


示例15: OrderBy_ThenBy_Skip_lifted_above_projection

        public void OrderBy_ThenBy_Skip_lifted_above_projection()
        {
            using (var context = new ArubaContext())
            {
                var query = context.Owners.OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Skip(5).Select(p => new { p.FirstName, p.Id, Foo = p.Id * 5 });
                var baseline = context.Owners.Select(p => new { p.FirstName, p.Id, Foo = p.Id * 5 }).OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Skip(5);
                Assert.Equal(baseline.ToString(), query.ToString());

                var results = query.ToList();
                var expected = context.Owners.ToList().OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Skip(5).Select(p => new { p.FirstName, p.Id, Foo = p.Id * 5 }).ToList();
                QueryTestHelpers.VerifyQueryResult(expected, results, (o, i) => o.Id == i.Id);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:13,代码来源:OrderByLiftingTests.cs


示例16: As_on_enum_not_supported

 public void As_on_enum_not_supported()
 {
     using (var context = new ArubaContext())
     {
         Assert.Throws<NotSupportedException>(
             () => context.AllTypes.Select(a => a.c33_enum as ArubaEnum?).ToList()).ValidateMessage(
             typeof(DbContext).Assembly(),
             "ELinq_UnsupportedIsOrAs",
             null, 
             "TypeAs", 
             "System.Data.Entity.TestModels.ArubaModel.ArubaEnum",
             "System.Nullable`1[[System.Data.Entity.TestModels.ArubaModel.ArubaEnum, EntityFramework.FunctionalTests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]");
     }
 }
开发者ID:jesusico83,项目名称:Telerik,代码行数:14,代码来源:EnumTests.cs


示例17: OrderBy_ThenBy_lifted_above_filter_without_clr_null_semantics

        public void OrderBy_ThenBy_lifted_above_filter_without_clr_null_semantics()
        {
            using (var context = new ArubaContext())
            {
                ((IObjectContextAdapter)context).ObjectContext.ContextOptions.UseCSharpNullComparisonBehavior = false;

                var query = context.Owners.OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Where(p => p.Id % 2 == 0);
                var baseline = context.Owners.Where(p => p.Id % 2 == 0).OrderByDescending(p => p.FirstName).ThenBy(p => p.Id);
                Assert.Equal(baseline.ToString(), query.ToString());

                var results = query.ToList();
                var expected = context.Owners.ToList().OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Where(p => p.Id % 2 == 0).ToList();
                QueryTestHelpers.VerifyQueryResult(expected, results, (o, i) => o.Id == i.Id);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:15,代码来源:OrderByLiftingTests.cs


示例18: GeographyDistanceFromMultiPolygon

        public void GeographyDistanceFromMultiPolygon()
        {
            var query = @"
select Edm.Distance(g.c31_geography,
    CAST(Edm.GeographyFromText(""MULTIPOLYGON (((-136.34518219919187 -45.444057174306, 100.08107983924452 0.029396673640468753, -12.771444237628261 0.029396673640468753, -136.34518219919187 -45.444057174306), (-136.34518219919187 -59.574853846584816, -6.6232329320655019 -12.718185214660565, 93.93286853368177 -12.718185214660565, -136.34518219919187 -59.574853846584816)))"", 4326) AS Edm.Geography))
from ArubaContext.AllTypes as g 
where (Edm.Distance(g.c31_geography,
    CAST(Edm.GeographyFromText(""MULTIPOLYGON (((-136.34518219919187 -45.444057174306, 100.08107983924452 0.029396673640468753, -12.771444237628261 0.029396673640468753, -136.34518219919187 -45.444057174306), (-136.34518219919187 -59.574853846584816, -6.6232329320655019 -12.718185214660565, 93.93286853368177 -12.718185214660565, -136.34518219919187 -59.574853846584816)))"", 4326) AS Edm.Geography)) <= 600000)";

            // verifying that all of the results are less than or equal to 600000 as specified in the query
            using (var db = new ArubaContext())
            using (var reader = QueryTestHelpers.EntityCommandSetup(db, query, "STDistance"))
            {
                VerifyValueCondition(reader, a => (double)a <= 600000);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:SpatialTests.cs


示例19: GroupBy_is_optimized_when_projecting_expression_containing_group_key

        public void GroupBy_is_optimized_when_projecting_expression_containing_group_key()
        {
            var expectedSql =
@"SELECT 
[Extent1].[Id] * 2 AS [C1]
FROM [dbo].[ArubaOwners] AS [Extent1]";

            using (var context = new ArubaContext())
            {
                var query = context.Owners.GroupBy(o => o.Id).Select(g => g.Key * 2);
                QueryTestHelpers.VerifyDbQuery(query, expectedSql);

                var results = query.ToList();
                var expected = context.Owners.ToList().GroupBy(o => o.Id).Select(g => g.Key * 2).ToList();
                QueryTestHelpers.VerifyQueryResult(expected, results, (o, i) => o == i);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:17,代码来源:GroupByOptimizationTests.cs


示例20: Include_on_many_to_many_relationship

 public void Include_on_many_to_many_relationship()
 {
     using (var context = new ArubaContext())
     {
         ((IObjectContextAdapter)context).ObjectContext.ContextOptions.LazyLoadingEnabled = false;
         var query = context.Configs.Include(c => c.Failures);
         var results = query.ToList();
         var failuresForConfigs = context.Configs.Select(r => r.Failures).ToList();
         for (var i = 0; i < results.Count; i++)
         {
             Assert.Equal(failuresForConfigs[i].Count, results[i].Failures.Count);
             var expectedFailures = failuresForConfigs[i].Select(t => t.Id).ToList();
             var actualFailures = results[i].Failures.Select(t => t.Id).ToList();
             Assert.True(Enumerable.SequenceEqual(expectedFailures, actualFailures));
         }
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:17,代码来源:IncludeTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# EntityClient.EntityConnection类代码示例发布时间:2022-05-26
下一篇:
C# SqlServer.SqlServerMigrationSqlGenerator类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap