HTML5技术

[开源].NET数据库访问框架Chloe.ORM - 我叫So(4)

字号+ 作者:H5之家 来源:博客园 2016-07-04 13:00 我要评论( )

IQueryUser q = context.QueryUser();var space = new char [] { ' ' };DateTime startTime = DateTime.Now; DateTime endTime = DateTime.Now.AddDays(1); q.Select(a = new {Id = a.Id,String_Length = ( int ?)a

IQuery<User> q = context.Query<User>(); var space = new char[] { ' ' }; DateTime startTime = DateTime.Now; DateTime endTime = DateTime.Now.AddDays(1); q.Select(a => new { Id = a.Id, String_Length = (int?)a.Name.Length,//LEN([Users].[Name]) Substring = a.Name.Substring(0),//SUBSTRING([Users].[Name],0 + 1,LEN([Users].[Name])) Substring1 = a.Name.Substring(1),//SUBSTRING([Users].[Name],1 + 1,LEN([Users].[Name])) Substring1_2 = a.Name.Substring(1, 2),//SUBSTRING([Users].[Name],1 + 1,2) ToLower = a.Name.ToLower(),//LOWER([Users].[Name]) ToUpper = a.Name.ToUpper(),//UPPER([Users].[Name]) IsNullOrEmpty = string.IsNullOrEmpty(a.Name),//太长,不贴了 Contains = (bool?)a.Name.Contains("s"),//太长,略 Trim = a.Name.Trim(),//RTRIM(LTRIM([Users].[Name])) TrimStart = a.Name.TrimStart(space),//LTRIM([Users].[Name]) TrimEnd = a.Name.TrimEnd(space),//RTRIM([Users].[Name]) StartsWith = (bool?)a.Name.StartsWith("s"),//太长,略 EndsWith = (bool?)a.Name.EndsWith("s"),//太长,略 SubtractTotalDays = endTime.Subtract(startTime).TotalDays,//CAST(DATEDIFF(DAY,@P_0,@P_1) SubtractTotalHours = endTime.Subtract(startTime).TotalHours,//CAST(DATEDIFF(HOUR,@P_0,@P_1) SubtractTotalMinutes = endTime.Subtract(startTime).TotalMinutes,//CAST(DATEDIFF(MINUTE,@P_0,@P_1) SubtractTotalSeconds = endTime.Subtract(startTime).TotalSeconds,//CAST(DATEDIFF(SECOND,@P_0,@P_1) SubtractTotalMilliseconds = endTime.Subtract(startTime).TotalMilliseconds,//CAST(DATEDIFF(MILLISECOND,@P_0,@P_1) Now = DateTime.Now,//GETDATE() UtcNow = DateTime.UtcNow,//GETUTCDATE() Today = DateTime.Today,//CAST(GETDATE() AS DATE) Date = DateTime.Now.Date,//CAST(GETDATE() AS DATE) Year = DateTime.Now.Year,//DATEPART(YEAR,GETDATE()) Month = DateTime.Now.Month,//DATEPART(MONTH,GETDATE()) Day = DateTime.Now.Day,//DATEPART(DAY,GETDATE()) Hour = DateTime.Now.Hour,//DATEPART(HOUR,GETDATE()) Minute = DateTime.Now.Minute,//DATEPART(MINUTE,GETDATE()) Second = DateTime.Now.Second,//DATEPART(SECOND,GETDATE()) Millisecond = DateTime.Now.Millisecond,//DATEPART(MILLISECOND,GETDATE()) DayOfWeek = DateTime.Now.DayOfWeek,//(DATEPART(WEEKDAY,GETDATE()) - 1) Int_Parse = int.Parse("1"),//CAST(N'1' AS INT) Int16_Parse = Int16.Parse("11"),//CAST(N'11' AS SMALLINT) Long_Parse = long.Parse("2"),//CAST(N'2' AS BIGINT) Double_Parse = double.Parse("3"),//CAST(N'3' AS FLOAT) Float_Parse = float.Parse("4"),//CAST(N'4' AS REAL) Decimal_Parse = decimal.Parse("5"),//CAST(N'5' AS DECIMAL) Guid_Parse = Guid.Parse("D544BC4C-739E-4CD3-A3D3-7BF803FCE179"),//CAST(N'xxx' AS UNIQUEIDENTIFIER) AS [Guid_Parse] Bool_Parse = bool.Parse("1"),//CASE WHEN CAST(N'1' AS BIT) = CAST(1 AS BIT) THEN CAST(1 AS BIT) WHEN NOT (CAST(N'1' AS BIT) = CAST(1 AS BIT)) THEN CAST(0 AS BIT) ELSE NULL END AS [Bool_Parse] DateTime_Parse = DateTime.Parse("1992-1-16"),//CAST(N'1992-1-16' AS DATETIME) AS [DateTime_Parse] B = a.Age == null ? false : a.Age > 1, }).ToList();

View Code

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • Dora.Interception: 一个为.NET Core度身定制的AOP框架 - Artech

    Dora.Interception: 一个为.NET Core度身定制的AOP框架 - Artech

    2017-05-02 11:00

  • 如何在 ASP.NET Core 中发送邮件 - Savorboard

    如何在 ASP.NET Core 中发送邮件 - Savorboard

    2017-05-02 08:02

  • 十二个 ASP.NET Core 例子 - Savorboard

    十二个 ASP.NET Core 例子 - Savorboard

    2017-04-27 16:01

  • HTML5 进阶系列:indexedDB 数据库 - _林鑫

    HTML5 进阶系列:indexedDB 数据库 - _林鑫

    2017-04-27 14:02

网友点评
>