Changing ntext to nvarchar using C# and Entity Framework
I have to add sorting to existing database created in SQL Server. The problem is that this database contains ntext columns that are not supported by LinQ's OrderBy method. The database was written in a code-first approach, so I have access to template of database, but I can't look at ready database working on the server. I've tried to change string type properties marking them as [Column(TypeName = "nvarchar(MAX)")] but then I got a Sequence contains no matching element exception which I don't know how to fix. This is the way that I wanted to sort my data(i got exception right in the below instruction: MyDatabase.MyTable.OrderBy(x => x.MyRow).Load(); Before I changed TypeName to nvarchar, I've got this error: Large objects (ntext and image) cannot be used in ORDER BY clauses Can somebody help me with fixing things up to make possible to sort data from database? I'll appreciate any kind of help. Thanks in advance!
In T-SQL you can solve this in many ways, may be you can adopt one of them for you too? ORDER BY (cast MyTextCol as nvarchar(max)) create a view from this table with that field casted as nvarchar(max) and use it instead of your table(even in future) ALTER TABLE myTable ALTER COLUMN myTextCol nvarchar(max) The last one solves your problem and takes no time to be made: it's just a metadata operation, nothing will reorganizen in your table for existing rows
c# home works can't solve [closed]
generic class for linq / lambda expression
Access Denied Exception with Message Dialog
ArgumentNullException in Json.NET 6.0.7 when deserializing into NameValueCollection
log4net enabled, but not creating any files
C# Pause Program Execution
Carriage return in XElement
Selecting decimal and string anonymous types in single LINQ query that's grouped
C# Calling a method in non referenced project because of circular dependency
How to use an unassigned local variable for an abstract class object
Why am I getting “An object reference is required for the non-static field, method, or property 'Photrax.App.DBPath.get'”?
Change display name of foreign key MVC
WPF C# - The member “template” cannot be recognized or is not accessible?
Prevent Entity Framework recreating databases but use existing databases instead
The page was not displayed because the request entity is too large.When Download a 10Gb ZIP file
Unexpected termination of SSIS when calling it from a stored procedure initiated by a C# service