I use c#, linq and EF4 I would like ask your help.
My question:
I have a linq query, but i need the result for this query be inserted in an array string.
Value added should be Title and ContentId (ContentId from EF is an INT but i need it as a string)
Please let me know, many thanks in advances!PS: Please post the full code 🙂
public static string[] GetCompletionList(string prefixText, string count)
{
using (CmsConnectionStringEntityDataModel context = new CmsConnectionStringEntityDataModel())
{
var queryTitle = (from content in context.CmsContents
select new
{
Title = content.Title, // String
ContentId = content.ContentId.ToString() // Int
}).ToArray();
return queryTitle;
}
If you want to have ContentId as a string, then do this:
queryTitle will be an array of the anonymous type created, which has two properties:
Both of type string.
If you don’t want to have an array of the anonymous type, but an array of strings, then use this code: