0
lalitChougule created
- ABP Framework version: v4.3.1
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no / yes
- Exception message and stack trace: N.A
- Steps to reproduce the issue:" N.A
Hi,
I am using PostgreSQL and I have created few views in my database. How do I query those views in my AppService ?
- Should I create Entity for view ? My view does not contain Id.
- I am using custom repository https://docs.abp.io/en/abp/4.3/Repositories#custom-repository-example, How do I make custom repository for view
- How do I declare property in DbContext ?
DbSet<ViewName>/DbQuery<ViewName>
Can you please provide step by step Implementation guide? I will be very helpful.
Thanks
4 Answer(s)
-
0
hi
https://github.com/abpframework/abp-samples/tree/master/StoredProcedureDemo
-
0
Hi maliming,
public async Task<List<string>> GetAdminUsernames(CancellationToken cancellationToken = default) { await EnsureConnectionOpenAsync(cancellationToken); using (var command = CreateCommand("SELECT * FROM dbo.UserAdminView", CommandType.Text)) { using (var dataReader = await command.ExecuteReaderAsync(cancellationToken)) { var result = new List<string>(); while (await dataReader.ReadAsync(cancellationToken)) { result.Add(dataReader["UserName"].ToString()); } return result; } } }
Is this the only way to query view ? Can't we access it like normal query i.e.
_someViewRepository.Where(x=> x.SomeValue == SomeValue).GroupBy(..)...
-
0
hi
You can try to use
ToView
.https://docs.microsoft.com/en-us/ef/core/modeling/keyless-entity-types?tabs=data-annotations https://docs.microsoft.com/en-us/ef/core/modeling/keyless-entity-types?tabs=data-annotations#mapping-to-database-objects
-
0
This question has been automatically marked as stale because it has not had recent activity.