This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT [x].[Id], | |
[x].[End], | |
[x].[Start] | |
FROM [Dates] AS [x] | |
WHERE [dbo].DATEDIFFDAY([x].[Start], [x].[End]) > 2 | |
/////////////////////////////////////////////////////////////////////////// | |
SELECT [x].[Id], | |
[x].[Start], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var date2 = db.Date | |
.Select(x => new | |
{ | |
x.Id, | |
x.Start, | |
x.End, | |
Diff = Database.DateDiffDay(x.Start, x.End) | |
}) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var date1 = db.Date | |
.Where(x => Database.DateDiffDay(x.Start, x.End) > 2) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DbFunction(FunctionName = "DATEDIFFDAY", Schema = "dbo")] | |
public static long DateDiffDay(DateTime start, DateTime end) | |
{ | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
ALTER FUNCTION [dbo].[DATEDIFFDAY] | |
( | |
@start DateTime, @end DateTime | |
) | |
RETURNS bigint | |
AS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec sp_executesql N'SELECT TOP(1) [e].[Id], [e].[Name], | |
[e].[Id], [e].[AddressCity], | |
[e].[AddressName], [e].[AddressNumber], [e].[AddressUf] | |
FROM [People] AS [e] | |
WHERE [e].[Id] = @__get_Item_0',N'@__get_Item_0 int',@__get_Item_0=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
People result = db.People.Find(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PeopleMap : IEntityTypeConfiguration<People> | |
{ | |
public void Configure(EntityTypeBuilder<People> builder) | |
{ | |
builder.ToTable("People") | |
.OwnsOne(x => x.Address, x => | |
{ | |
x.Property(a => a.City) | |
.HasColumnName("AddressCity") | |
.IsRequired().HasMaxLength(50); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class People | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public Address Address { get; set; } | |
} | |
public class Address | |
{ | |
public string Name { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT TOP(1) [x].[Id], [x].[Description], [x].[Id], [x].[Amount], [x].[Price] | |
FROM [Products] AS [x] | |
WHERE [x].[Id] = 1 |
NewerOlder