Create WCF Project

Open Visual Studio 2017 Community. Create New Project name and save solution in C:\UsedCar\UsedCarService and click Next button

Create WCF Project

Create a folder Model for UsedCar project

Create WCF Project

Right click Model and selecte New Item

Create WCF Project

Select ADO.NET Entity Model and Name UsedCarDBEntity and name UsedCarDBEntity

Create WCF Project

Select Entity FrameWork from database.

Create WCF Project

Create connection string.

Create WCF Project

Enter your database name and select UsedCar database .

Create WCF Project

Click Next

Create WCF Project

Select Entity Framework 5.0. Click Next

Create WCF Project

Select All tables Click Finish

WCF Sevice

IService1.

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace UsedCarService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface ICableWireService
    {
        [OperationContract]
        [WebInvoke(Method = "GET",
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "/GetBodyType/")]
        List<AutoDataContract.BodyTypeDataContract> GetBodyType();
        [OperationContract]
        [WebInvoke(Method = "GET",
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "/GetAutoColor/")]
        List<AutoDataContract.AutoColorDataContract> GetAutoColor();
        [OperationContract]
        [WebInvoke(Method = "GET",
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "/GetAutoStatus/")]
        List<AutoDataContract.AutoStatusDataContract> GetAutoStatus();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetYears/")]
        List<AutoDataContract.YearDataContract> GetYears();
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetAutoMake/")]
        List<AutoDataContract.MakeDataContract> GetAutoMake();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetAutoModels/{autoMake}")]
        List<AutoDataContract.ModelDataContract> GetAutoModels(string autoMakeId);
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetAutoDoor/")]
        List<AutoDataContract.AutoDoorDataContract> GetAutoDoor();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetAutoMiles/")]
        List<AutoDataContract.AutoMileDataContract> GetAutoMiles();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/GetAutoEngine/")]
        List<AutoDataContract.AutoEngineDataContract> GetAutoEngine();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedMaint/")]
        List<AutoDataContract.AutoUsedDataContract> AutoUsedMaint();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedSale/")]
        List<AutoDataContract.AutoUsedDataContract> AutoUsedSale();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedPaging/{pageSize}/{pageNumber}")]
        List<AutoDataContract.AutoUsedDataContract> AutoUsedPaging(string pageSize, string pageNumber);
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoRecordCount/")]
        List<AutoDataContract.RecordCount> AutoRecordCount();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedBanner/")]
        List<AutoDataContract.AutoUsedDataContract> AutoUsedBanner();
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedDetail/{autoUsedId}")]
        AutoDataContract.AutoUsedDataContract AutoUsedDetail(string autoUsedId);
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoUsedSearch/{bodyType}/{autoMake}/{autoModel}/{autoYear}/{autoColor}")]
        List<AutoDataContract.AutoUsedDataContract> AutoUsedSearch(string bodyType, string autoMake, string autoModel, string autoYear, string autoColor);
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/AutoMakeSearch/{autoMake}")]
        List<AutoDataContract.AutoUsedDataContract> AutoMakeSearch(string autoMake);
        [OperationContract]
        [WebInvoke(Method = "GET",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "/Transmission/")]
        List<AutoDataContract.TransmissionDataContract> Transmission();
    }
    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    public class AutoDataContract
    {
        [DataContract]
        public class BodyTypeDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string bodyType { getset; }
        }
        [DataContract]
        public class AutoColorDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string Color { getset; }
            [DataMember]
            public string Rgb { getset; }
        }
        [DataContract]
        public class AutoStatusDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string autoStatus1 { getset; }
        }
        [DataContract]
        public class MonthDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string vMonth { getset; }
        }
        [DataContract]
        public class YearDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public int autoYear1 { getset; }
        }
        [DataContract]
        public class MakeDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string autoMake1 { getset; }
        }
        [DataContract]
        public class ModelDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string autoMake { getset; }
            [DataMember]
            public string autoModel1 { getset; }
        }
        [DataContract]
        public class AutoDoorDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public int autoDoor { getset; }
        }
        [DataContract]
        public class AutoMileDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public int autoMiles1 { getset; }
        }
        [DataContract]
        public class AutoEngineDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public int autoEngine1 { getset; }
        }
        [DataContract]
        public class AutoUsedDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string stockNumber { getset; }
            [DataMember]
            public string userAccount { getset; }
            [DataMember]
            public string bodyType { getset; }
            [DataMember]
            public int autoYear { getset; }
            [DataMember]
            public string autoMake { getset; }
            [DataMember]
            public string autoModel { getset; }
            [DataMember]
            public string exteriorColor { getset; }
            [DataMember]
            public string interiorColor { getset; }
            [DataMember]
            public int autoEngine { getset; }
            [DataMember]
            public string transmission { getset; }
            [DataMember]
            public string MPGRange { getset; }
            [DataMember]
            public int autoDoor { getset; }
            [DataMember]
            public int autoMileage { getset; }
            [DataMember]
            public decimal salePrice { getset; }
            [DataMember]
            public decimal newPrice { getset; }
            [DataMember]
            public string autoStatus { getset; }
            [DataMember]
            public int banner { getset; }
            [DataMember]
            public string picture { getset; }
            [DataMember]
            public string notes { getset; }
            [DataMember]
            public string VIN { getset; }
        }
        [DataContract]
        public class SaleStatusContact
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string saleStatus1 { getset; }
        }
        [DataContract]
        public class RecordCount
        {
            [DataMember]
            public int ID { getset; }
        }
        [DataContract]
        public class AutoUsedMake
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string autoMake { getset; }
            [DataMember]
            public int makeCount { getset; }
        }
        [DataContract]
        public class TransmissionDataContract
        {
            [DataMember]
            public int ID { getset; }
            [DataMember]
            public string transmission1 { getset; }
        }
    }
}

Service1.svc

.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using UsedCarService.Models;
namespace UsedCarService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : ICableWireService
    {
        UsedCarDBEntity ADE;
        public Service1()
        {
            ADE = new UsedCarDBEntity();
        }
        public List<AutoDataContract.BodyTypeDataContract> GetBodyType()
        {
            var query = (from a in ADE.AutoBodyType select a);
            List<AutoDataContract.BodyTypeDataContract> BodyTypeList = new List<AutoDataContract.BodyTypeDataContract>();
            query.ToList().ForEach(rec =>
            {
                BodyTypeList.Add(new AutoDataContract.BodyTypeDataContract
                {
                    ID = rec.ID,
                    bodyType = rec.bodyType
                });
            });
            return BodyTypeList;
        }
        public List<AutoDataContract.AutoColorDataContract> GetAutoColor()
        {
            var query = (from a in ADE.AutoColor select a);
            List<AutoDataContract.AutoColorDataContract> AutoColorList = new List<AutoDataContract.AutoColorDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoColorList.Add(new AutoDataContract.AutoColorDataContract
                {
                    ID = rec.ID,
                    Color = rec.Color,
                    Rgb = rec.Rgb
                });
            });
            return AutoColorList;
        }
        public List<AutoDataContract.AutoStatusDataContract> GetAutoStatus()
        {
            var query = (from a in ADE.AutoStatus select a);
            List<AutoDataContract.AutoStatusDataContract> AutoStatusList = new List<AutoDataContract.AutoStatusDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoStatusList.Add(new AutoDataContract.AutoStatusDataContract
                {
                    ID = rec.ID,
                    autoStatus1 = rec.autoStatus1
                });
            });
            return AutoStatusList;
        }
        public List<AutoDataContract.AutoEngineDataContract> GetAutoEngine()
        {
            var query = (from a in ADE.AutoEngine select a);
            List<AutoDataContract.AutoEngineDataContract> AutoEngineList = new List<AutoDataContract.AutoEngineDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoEngineList.Add(new AutoDataContract.AutoEngineDataContract
                {
                    ID = rec.ID,
                    autoEngine1 = rec.autoEngine1
                });
            });
            return AutoEngineList;
        }
        public List<AutoDataContract.YearDataContract> GetYears()
        {
            var query = (from a in ADE.AutoYear select a);
            List<AutoDataContract.YearDataContract> YearList = new List<AutoDataContract.YearDataContract>();
            query.ToList().ForEach(rec =>
            {
                YearList.Add(new AutoDataContract.YearDataContract
                {
                    ID = rec.ID,
                    autoYear1 = rec.autoYear1
                });
            });
            return YearList;
        }
        public string AutoMakeName(string autoMakeId)
        {
            //Get a single autobid object
            var query = (from A in ADE.AutoMake
                         where A.ID.Equals(autoMakeId)
                         select A.autoMake1).FirstOrDefault();
            return query.ToString().Trim();
            //write database related data retrival logic here.
        }
        public List<AutoDataContract.MakeDataContract> GetAutoMake()
        {
            var query = (from a in ADE.AutoMake select a);
            List<AutoDataContract.MakeDataContract> AutoMakeList = new List<AutoDataContract.MakeDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoMakeList.Add(new AutoDataContract.MakeDataContract
                {
                    ID = rec.ID,
                    autoMake1 = rec.autoMake1
                });
            });
            return AutoMakeList;
        }
        public List<AutoDataContract.ModelDataContract> GetAutoModels(string autoMakeID)
        {
            var query = (from A in ADE.AutoModel
                         where A.autoMakeId.Equals(autoMakeID)
                         select A);
            //    var query = (from a in ADE.QuoteItems select a);
            List<AutoDataContract.ModelDataContract> autoModelList = new List<AutoDataContract.ModelDataContract>();
            query.ToList().ForEach(rec =>
            {
                autoModelList.Add(new AutoDataContract.ModelDataContract
                {
                    ID = rec.ID,
                    autoMake = rec.autoMake,
                    autoModel1 = rec.autoModel1
                });
            });
            return autoModelList;
        }
        public List<AutoDataContract.AutoDoorDataContract> GetAutoDoor()
        {
            var query = (from a in ADE.AutoDoors select a);
            List<AutoDataContract.AutoDoorDataContract> AutoDoorList = new List<AutoDataContract.AutoDoorDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoDoorList.Add(new AutoDataContract.AutoDoorDataContract
                {
                    ID = rec.ID,
                    autoDoor = rec.autoDoor
                });
            });
            return AutoDoorList;
        }
        public List<AutoDataContract.AutoMileDataContract> GetAutoMiles()
        {
            var query = (from a in ADE.AutoMiles select a);
            List<AutoDataContract.AutoMileDataContract> AutoMileList = new List<AutoDataContract.AutoMileDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoMileList.Add(new AutoDataContract.AutoMileDataContract
                {
                    ID = rec.ID,
                    autoMiles1 = rec.autoMiles1
                });
            });
            return AutoMileList;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoUsedSale()
        {
            var query = (from a1 in ADE.AutoUsed select a1);
            List<AutoDataContract.AutoUsedDataContract> AutoUsedList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoUsedList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes
                });
            });
            return AutoUsedList;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoUsedPaging(string pageSize, string pageNumber)
        {
            int pageZiz = Convert.ToInt32(pageSize);
            int pageNo = Convert.ToInt32(pageNumber);
            var query = (from autoUsed in ADE.AutoUsed
                         where autoUsed.autoStatus != "Banner" && autoUsed.autoStatus != "Hide"
                         select autoUsed)
                         .OrderBy(x => x.ID)
                         .Skip((pageNo - 1) * pageZiz)
                         .Take(pageZiz);
            List<AutoDataContract.AutoUsedDataContract> AutoUsedList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoUsedList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes,
                    VIN = rec.VIN
                });
            });
            return AutoUsedList;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoUsedMaint()
        {
            var query = (from a1 in ADE.AutoUsed select a1);
            List<AutoDataContract.AutoUsedDataContract> AutoUsedList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoUsedList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes,
                    VIN = rec.VIN
                });
            });
            return AutoUsedList;
        }
        public List<AutoDataContract.RecordCount> AutoRecordCount()
        {
            var query = (from a1 in ADE.AutoUsed
                         where a1.autoStatus != "Banner"
                         select a1);
            List<AutoDataContract.RecordCount> aUsedList = new List<AutoDataContract.RecordCount>();
            query.ToList().ForEach(rec =>
            {
                aUsedList.Add(new AutoDataContract.RecordCount
                {
                    ID = rec.ID,
                });
            });
            return aUsedList;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoUsedBanner()
        {
            var query = (from a1 in ADE.AutoUsed
                         where a1.autoStatus == "Banner" && a1.autoStatus != "Sold" && a1.autoStatus != "Hide"
                         select a1);
            List<AutoDataContract.AutoUsedDataContract> AutoUsedList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                AutoUsedList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes,
                    VIN = rec.VIN
                });
            });
            return AutoUsedList;
        }
        public AutoDataContract.AutoUsedDataContract AutoUsedDetail(string autoUsedId)
        {
            AutoDataContract.AutoUsedDataContract autoUsedDetail = new AutoDataContract.AutoUsedDataContract();
            try
            {
                int autoUsedid = Convert.ToInt32(autoUsedId);
                var query = (from autoDetail in ADE.AutoUsed
                             where autoDetail.ID.Equals(autoUsedid)
                             select autoDetail).Distinct().FirstOrDefault();
                autoUsedDetail.ID = query.ID;
                autoUsedDetail.stockNumber = query.stockNumber;
                autoUsedDetail.bodyType = query.bodyType;
                autoUsedDetail.autoYear = query.autoYear;
                autoUsedDetail.autoMake = query.autoMake;
                autoUsedDetail.autoModel = query.autoModel;
                autoUsedDetail.exteriorColor = query.exteriorColor;
                autoUsedDetail.interiorColor = query.interiorColor;
                autoUsedDetail.autoEngine = query.autoEngine;
                autoUsedDetail.transmission = query.transmission;
                autoUsedDetail.MPGRange = query.MPGRange;
                autoUsedDetail.autoDoor = query.autoDoor;
                autoUsedDetail.autoMileage = query.autoMileage;
                autoUsedDetail.salePrice = query.salePrice;
                autoUsedDetail.newPrice = query.newPrice;
                autoUsedDetail.autoStatus = query.autoStatus;
                autoUsedDetail.picture = query.picture;
                autoUsedDetail.notes = query.notes;
                autoUsedDetail.VIN = query.VIN;
            }
            catch (Exception ex)
            {
                throw new FaultException<string>
                        (ex.Message);
            }
            return autoUsedDetail;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoUsedSearch(string bodyType, string autoMake, string autoModel, string autoYear, string autoColor)
        {
            int modelYear = Convert.ToInt32(autoYear);
            var query = (from autoType in ADE.AutoUsed
                         where autoType.bodyType == bodyType && autoType.autoMake == autoMake && autoType.autoModel == autoModel && autoType.autoYear == modelYear && autoType.exteriorColor != autoColor && autoType.autoStatus != "Hide"
                         select autoType);
            List<AutoDataContract.AutoUsedDataContract> ResultList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                ResultList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes,
                    VIN = rec.VIN
                });
            });
            return ResultList;
        }
        public List<AutoDataContract.AutoUsedDataContract> AutoMakeSearch(string autoMake)
        {
            var query = (from autoType in ADE.AutoUsed
                         where autoType.autoMake == autoMake && autoType.autoStatus != "Hide"
                         select autoType);
            List<AutoDataContract.AutoUsedDataContract> ResultList = new List<AutoDataContract.AutoUsedDataContract>();
            query.ToList().ForEach(rec =>
            {
                ResultList.Add(new AutoDataContract.AutoUsedDataContract
                {
                    ID = rec.ID,
                    stockNumber = rec.stockNumber,
                    bodyType = rec.bodyType,
                    autoYear = rec.autoYear,
                    autoMake = rec.autoMake,
                    autoModel = rec.autoModel,
                    exteriorColor = rec.exteriorColor,
                    interiorColor = rec.interiorColor,
                    autoEngine = rec.autoEngine,
                    transmission = rec.transmission,
                    MPGRange = rec.MPGRange,
                    autoDoor = rec.autoDoor,
                    autoMileage = rec.autoMileage,
                    salePrice = rec.salePrice,
                    newPrice = rec.newPrice,
                    autoStatus = rec.autoStatus,
                    picture = rec.picture,
                    notes = rec.notes,
                    VIN = rec.VIN
                });
            });
            return ResultList;
        }
        public string ContactMessage(string VisitorName, string VisitorEmail, string Subject, string VisitorMessage, string ipAddress)
        {
            AddContactMessage(VisitorName, VisitorEmail, Subject, VisitorMessage, ipAddress);
            return "Save Contact Message"//var query = (from a in ADE.AutoUsed select a);
        }
        public void AddContactMessage(string VisitorName, string VisitorEmail, string Subject, string VisitorMessage, string ipAddress)
        {
            DateTime now = DateTime.Now;
            try
            {
                ContactUs cMessage = ADE.ContactUs.Create();
                cMessage.VisitorName = VisitorName;
                cMessage.VisitorEmail = VisitorEmail;
                cMessage.Subject = Subject;
                cMessage.VisitorMessage = VisitorMessage;
                cMessage.ipAddress = ipAddress;
                cMessage.ContactDate = Convert.ToDateTime(now);
                ADE.ContactUs.Add(cMessage);
                ADE.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<string>
                        (ex.Message);
            }
        }
        public List<AutoDataContract.TransmissionDataContract> Transmission()
        {
            var query = (from a1 in ADE.Transmission select a1);
            List<AutoDataContract.TransmissionDataContract> transmissionList = new List<AutoDataContract.TransmissionDataContract>();
            query.ToList().ForEach(rec =>
            {
                transmissionList.Add(new AutoDataContract.TransmissionDataContract
                {
                    ID = rec.ID,
                    transmission1 = rec.transmission1
                });
            });
            return transmissionList;
        }
    }
}

Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="UsedCarService.Service1" behaviorConfiguration="serviceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="UsedCarService.IService1" behaviorConfiguration="RESTEndpointBehavior"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:59040/Service1.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="RESTEndpointBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="webHttpBinding" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <standardEndpoints>
      <webScriptEndpoint>
        <standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
      </webScriptEndpoint>
    </standardEndpoints>
  </system.serviceModel>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization, X-Requested-With" />
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <connectionStrings>
    <add name="UsedCarData" connectionString="metadata=res://*/Model.UsedCarData.csdl|res://*/Model.UsedCarData.ssdl|res://*/Model.UsedCarData.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=..\SQLEXPRESS;initial catalog=BPAuto;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

No results found