You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have plain sql with paging and search syntax, i want to execute it map tables to object and take total count. My code is like that:
var selectSql = " SELECT TotalCount = COUNT(*) OVER(), E.* FROM " + fullName + " E " + whereSql;
var rows = context.Set<EventTable>()
.FromSql<EventTable>(selectSql, parameters.Select(p => p.Value).ToArray())
.ToArray();
var totalCount = context.Entry(rows.First()).Property<int>("TotalCount").CurrentValue;
But i have problem when i trying to take property that not exist in database table. I don't need this property in a table, i just want to calculate it in select query. Why i can't do this?
In older version i can have class like below and map query into this class, in new framework its does not work because its throwing exception that entity of this type not found or something like that (don't remember now). If i add this new class in context, then its throwing new exceptions about discriminator property and etc.
[NotMapped]
public class EventSearchTable : EventTable
{
[Column("total_count")]
[Required]
public int TotalCount { get; set; }
}
The text was updated successfully, but these errors were encountered:
Borlay
changed the title
Get property that are calculated in select
Get property that are calculated in select query
Apr 19, 2016
Borlay
changed the title
Get property that are calculated in select query
Get property which is calculated in select query
Apr 20, 2016
I have plain sql with paging and search syntax, i want to execute it map tables to object and take total count. My code is like that:
But i have problem when i trying to take property that not exist in database table. I don't need this property in a table, i just want to calculate it in select query. Why i can't do this?
In older version i can have class like below and map query into this class, in new framework its does not work because its throwing exception that entity of this type not found or something like that (don't remember now). If i add this new class in context, then its throwing new exceptions about discriminator property and etc.
The text was updated successfully, but these errors were encountered: