Remove the id property from the view.

pull/2000/head
maliming 6 years ago
parent b4940f135c
commit 6944da4a82

@ -62,7 +62,7 @@ namespace Volo.Abp.EntityFrameworkCore
context.GetService<IRelationalDatabaseCreator>().CreateTables();
context.Database.ExecuteSqlRaw(
@"CREATE VIEW View_PersonView AS
SELECT Id, Name, CreationTime, Birthday, LastActive FROM People");
SELECT Name, CreationTime, Birthday, LastActive FROM People");
}
return connection;

@ -16,9 +16,9 @@ namespace Volo.Abp.TestApp.EntityFrameworkCore
{
}
public async Task<PersonView> GetViewAsync(Guid id)
public async Task<PersonView> GetViewAsync(string name)
{
return await DbContext.PersonView.Where(x => x.Id == id).FirstOrDefaultAsync();
return await DbContext.PersonView.Where(x => x.Name == name).FirstOrDefaultAsync();
}
}
}

@ -8,6 +8,6 @@ namespace Volo.Abp.TestApp.Domain
{
public interface IPersonRepository : IBasicRepository<Person, Guid>
{
Task<PersonView> GetViewAsync(Guid id);
Task<PersonView> GetViewAsync(string name);
}
}

@ -5,8 +5,6 @@ namespace Volo.Abp.TestApp.Domain
{
public class PersonView
{
public Guid Id { get; set; }
public string Name { get; set; }
public DateTime CreationTime { get; set; }

@ -48,14 +48,14 @@ namespace Volo.Abp.TestApp.Testing
[Fact]
public async Task DateTime_Kind_Should_Be_Normalized_To_UTC_View_Test()
{
var personId = Guid.Parse("7a942bca-c911-4473-93aa-2daf88e18fb9");
await _personRepository.InsertAsync(new Person(personId, "bob lee", 18)
var personName = "bob lee";
await _personRepository.InsertAsync(new Person(Guid.NewGuid(), personName, 18)
{
Birthday = DateTime.Parse("2020-01-01 00:00:00"),
LastActive = DateTime.Parse("2020-01-01 00:00:00"),
}, true);
var person = await _personRepository.GetViewAsync(personId);
var person = await _personRepository.GetViewAsync(personName);
person.ShouldNotBeNull();
person.CreationTime.Kind.ShouldBe(DateTimeKind.Utc);

Loading…
Cancel
Save