Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
deleted 132 characters in body
Source Link
Manfred Radlwimmer
  • 13.4k
  • 13
  • 55
  • 65

I am trying to fetch a column value and convert it as a list of formatted string value and iI tried the below code

 List<string> _names = (from p in context.RakHolders  select   select string.Format("{0},{1}", p.Name.Split(',')[0].Trim(), p.Name.Split(',')[1].Trim() ))   .ToList(); 

My intention is to get a list of names with no unwanted space between commas in the column Name

I am getting exception while executing this line as

 An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object, System.Object)' method, and this method cannot be translated into a store expression. 

An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

Additional information: LINQ to Entities does not recognize the method
'System.String Format(System.String, System.Object, System.Object)' method, and this method cannot be translated into a store expression.

How can iI make this workingwork [get a list of formatted column values ]withvalues] with LINQ

I am trying to fetch a column value and convert it as a list of formatted string value and i tried the below code

 List<string> _names = (from p in context.RakHolders    select string.Format("{0},{1}", p.Name.Split(',')[0].Trim(), p.Name.Split(',')[1].Trim() ))   .ToList(); 

My intention is to get a list of names with no unwanted space between commas in the column Name

I am getting exception while executing this line as

 An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object, System.Object)' method, and this method cannot be translated into a store expression. 

How can i make this working [get a list of formatted column values ]with LINQ

I am trying to fetch a column value and convert it as a list of formatted string value and I tried the below code

List<string> _names = (from p in context.RakHolders select string.Format("{0},{1}", p.Name.Split(',')[0].Trim(), p.Name.Split(',')[1].Trim())) .ToList(); 

My intention is to get a list of names with no unwanted space between commas in the column Name

I am getting exception while executing this line as

An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

Additional information: LINQ to Entities does not recognize the method
'System.String Format(System.String, System.Object, System.Object)' method, and this method cannot be translated into a store expression.

How can I make this work [get a list of formatted column values] with LINQ

Source Link
Sebastian
  • 4.9k
  • 19
  • 89
  • 161

LINQ Select formatted values as a LIST

I am trying to fetch a column value and convert it as a list of formatted string value and i tried the below code

 List<string> _names = (from p in context.RakHolders select string.Format("{0},{1}", p.Name.Split(',')[0].Trim(), p.Name.Split(',')[1].Trim() )) .ToList(); 

My intention is to get a list of names with no unwanted space between commas in the column Name

I am getting exception while executing this line as

 An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object, System.Object)' method, and this method cannot be translated into a store expression. 

How can i make this working [get a list of formatted column values ]with LINQ