troubleshooting Question

IEnumerable<T> to a List<T>

Avatar of sbornstein2
sbornstein2 asked on
C#ASP.NET
8 Comments1 Solution234 ViewsLast Modified:
Hello all,

I have the following class currently:
  [Serializable]
    [CollectionDataContract(Name = "Customers", ItemName = "Customer", Namespace = "")]
    public class Customers : List<Customer>
    { }

    [DataContract(Namespace = "")]
    public class Customer
    {
        [Key]
        [DataMember]
        public int CustomerID { get; set; }
        [DataMember]
        public string CustomerCode { get; set; }
        [DataMember]
        public string CustomerName { get; set; }
    }

I then have an IEnumerable coming back from the DapperORM tool that comes back as IEnumerable<Customer>.  How do I handle this I am getting issues everytime on casts etc?

That code sample is:
  public Customers  GetCustomers()
        {
            using (conn)
            {
                if (filters.Count() == 0)
                { 
                    return conn.GetList<Customer>(); //this needs to be changed to pass the Customers list.
                }
            }
        }

I can't change the dapper side it needs a <T> passed and returns an IEnumerable<Customer> in this case.
ASKER CERTIFIED SOLUTION
it_saige
Developer
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros