Questions tagged [dbfunctions]
28 questions
14
votes
2 answers
How can I use SQL Server JSON_VALUE function in EF 6 Code First for classic .NET
How can I use SQL Server JSON_VALUE function in EF 6 Code First for classic .NET? I found I can do it in EF Core like this:
public static class JsonExtensions
{
public static string JsonValue(string column, [NotParameterized] string path)
{
…

Jonatan Dragon
- 4,675
- 3
- 30
- 38
6
votes
2 answers
Mixing EF Core Convensions and DBFunction for a JObject property
I have an entity with properties of type JObject and I need to be able to use DbFunctions against those properties.
When I execute, the project throws an exception saying that DbFunction doesn't allows parameters of type JObject.
The entity is…

Leonardo Neninger
- 586
- 4
- 18
4
votes
1 answer
convert sql results to ActiveRecord relation
In the following,
@records = ActiveRecord::Base.connection.exec_query(sql)
The "sql" string is a call to a db function that returns a table.
This line of code returns #

Tim Koelkebeck
- 795
- 2
- 9
- 18
4
votes
3 answers
DbFunctions DiffDays Gives wrong answer
I want to get a list from DataBase, where MyDate is today or tomarrow.
I wrote the following code.
_Log("Now: " + DateTime.Now.ToString());
var v = db_TS.TS_Test.Where(x => DbFunctions.DiffDays(x.MyDate,DateTime.Now) < 2);
foreach (var item in…

Ruby Nanthagopal
- 596
- 1
- 5
- 17
3
votes
1 answer
Call DbFunction with EF core 2.1
I try to call a scalar function stored in my DB.
Here is my code:
public class PronosticDbContext : DbContext
{
public PronosticDbContext(DbContextOptions options) : base(options)
{
}
[DbFunction(FunctionName =…

Shadam
- 1,041
- 13
- 25
3
votes
1 answer
LinqPad 5 : The name 'DbFunctions' does not exist in the current context
I am trying to use the following in LinqPad (C# Statement):
DbFunctions.TruncateTime(mvOutDt).ToString()
It doesn't seems to recognize DbFunctions. I have added the System.Data.Entity reference. I even tried to fully qualify it using…

DJ Burb
- 2,346
- 2
- 29
- 38
2
votes
2 answers
Does DbFunctions.TruncateTime behave differently in different server time zones?
I'm not sure that my question Title is perfect - so please allow me to explain a little further.
Here's a snapshot of some test data:
Here's my code:
Function TestDb() As ActionResult
Dim clientLocId As Integer = 23
Dim showDate As New Date
…

HumbleBeginnings
- 1,009
- 10
- 22
1
vote
0 answers
Mapping a DbFunction to an InExpression
In EF Core, I'm trying to map a custom function to an InExpression using the HasDbFunction functionality. I'm having trouble getting it to work as EF keeps complaining:
'The parameter 'enumerable' for the DbFunction…

MgSam
- 12,139
- 19
- 64
- 95
1
vote
0 answers
.NET5.0 Ensure that the return type can be mapped by the current provider
Model:
public partial class FN_Result
{
public string UserImage { get; set; }
public string UserName { get; set; }
public string Title { get; set; }
public int messageId { get; set; }
public int SenderId { get; set; }
public…

Rafael
- 1,099
- 5
- 23
- 47
1
vote
0 answers
How to use a Database-first registered DbFunction inside another context with Linq To Entities?
I would provide an Oracle Database function (ie. RemoveDiacritics) in my low-layer C# package which is installed on multiple websites, to allow these applications to use my custom function inside their Linq To Entities queries. The goal is to…

Sackey
- 392
- 2
- 11
1
vote
1 answer
EF Core Full-text search: parameterized keySelector could not be translated into SQL
I'd like to create a generic extension method which allow me to use Full-text search.
● The code below works:
IQueryable query = Repository.AsQueryable();
if (!string.IsNullOrEmpty(searchCondition.Name))
query = query.Where(e =>…

trgiangvp3
- 253
- 3
- 9
1
vote
1 answer
How to use DbFunctions in LINQ?
I have this LINQ to entity:
var result = (from inspArch in inspectionArchives
from inspAuth in inspArch.InspectionAuthority
group new { inspArch, inspAuth } by inspArch.CustomerId into g
select new
…

Michael
- 13,950
- 57
- 145
- 288
1
vote
1 answer
How to subtract hours using DbFunctions?
How to subtract hours using DbFunctions?
I'm using .Net framework 4.5 and Entity Framework 6.0
Here's the code I wrote.
var _temp = (from x in context.LOG_ACTIVITIES
...
select new
{
…

Vond Ritz
- 2,022
- 14
- 15
0
votes
0 answers
Add EF Core 6 OPENJSON translation which passes the column name instead of string
I am working on a legacy project which uses SQL Server and stores JSON is some of the columns, which has been upgraded to EF Core 6.
My main issue is that I have an old query which probably ran client-side in previous versions, but now fails at…

vgru
- 49,838
- 16
- 120
- 201
0
votes
1 answer
How to make a copy of trigger function in postgreSQL pgadmin 4?
I am using postgreSQL with pgAdmin 4 and I have created a database function named "fn_test1()". I want to delete this function and before delete this function, I want to create a backup function named "fn_test1_bk()" . Can anyone help me to do this?

Nirodha Wickramarathna
- 259
- 1
- 4
- 24