Cannot convert int to string

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
thinkrama
Posts: 2
Joined: Fri 25 Feb 2011 15:27

Cannot convert int to string

Post by thinkrama » Fri 25 Feb 2011 15:38

Have an entity with couple of properties

public string Suffix { get; set; }
public int Prefix { get; set; }

- Concatenate string.concat(Prefix, Suffix) - errored out
- Tried SqlFunctions.StringConvert() - errored out
- Also tried creating a partial class and still the same issue

concat error:
Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.

sqlfunctions error:
The specified method 'System.String StringConvert(System.Nullable`1[System.Double])' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression.

In SQL Server, this works without any issues.

Any help is still appreciated

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 25 Feb 2011 17:09

Try using the OracleFunctions class:

Code: Select all

Devart.Data.Oracle.Entity.OracleFunctions.ToChar(m.Id) + m.Field

thinkrama
Posts: 2
Joined: Fri 25 Feb 2011 15:27

It worked :)

Post by thinkrama » Fri 25 Feb 2011 17:47

Thank you very much AndreyR, it worked as expected with no errors.

Actual Code Snippet:
CreditNumber = c.CREDIT_NBR_PFX + OracleFunctions.ToChar((decimal)c.CREDIT_NBR_SFX),

dewey
Posts: 2
Joined: Wed 27 Jul 2011 06:52
Location: lahore
Contact:

Post by dewey » Fri 29 Jul 2011 12:37

Thanks from me too about this error from both of you and also for the actual code thanks it really gives me help thanks

Post Reply