Johnny Johnny - 1 year ago 139
C# Question

Generic List to EntitySet Conversion

How do I Convert a

to a

Answer Source

Don't think you can convert a List<T> to an EntitySet<T> but you can put the content of your list in the entitySet.

var list = new List<string> { "a", "b", "c" };
var entitySet = new EntitySet<string>();

Here's a extension method for that:

public static EntitySet<T> ToEntitySet<T>(this IEnumerable<T> source) where T : class
    var es = new EntitySet<T>();
    return es;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download