Problem beim Konvertieren von int in string in Linq in Entities

var items = from c in contacts
            select new ListItem
            {
                Value = c.ContactId, //Cannot implicitly convert type 'int' (ContactId) to 'string' (Value).
                Text = c.Name
            };
var items = from c in contacts
            select new ListItem
            {
                Value = c.ContactId.ToString(), //Throws exception: ToString is not supported in linq to entities.
                Text = c.Name
            };

Kann ich das überhaupt erreichen? Beachten Sie, dass es in VB.NET kein Problem gibt, das erste Snippet zu verwenden, es funktioniert einfach großartig, VB ist flexibel, ich bin nicht in der Lage, mich an die Strenge von C # zu gewöhnen !!!

Antworten auf die Frage(15)

Ihre Antwort auf die Frage