1
Answer

WCF dataContracts and LINQ to SQL

Jason Addique

Jason Addique

14y
7.1k
1
Iam trying to create a basic WCF service library web service which connects to a database via LINQ to SQL and returns list of DataContract marked objects but I keep recieving this error:

Error    1    Cannot implicitly convert type 'System.Linq.IQueryable<CwkServer.getCarDetails>' to 'System.Collections.Generic.List<CwkServer.getCarDetails>'. An explicit conversion exists (are you missing a cast?)    C:\Users\Cameron\Documents\Visual Studio 2008\Projects\CwkServer\CwkServer\CwkService.cs    34    22    CwkServer

I feel its just a basic error on my part but cant see it. Here is my code

cwkService
       public List<getCarDetails> getDetails()
       {
           List<getCarDetails> details = from list in db.Listings
                     select new getCarDetails
                     {
                         CarName = list.CarType.CarTypeName,
                         NumDoors = list.CarType.NumberOfDoors,
                     };
           return details;
}

ICwkService

  [DataContract]
    public class getCarDetails
    {
        string carName;
        int numDoors;

        [DataMember]
        public string CarName
        {
            get { return carName; }
            set { carName = value; }
        }

        [DataMember]
        public int NumDoors
        {
            get { return numDoors; }
            set { numDoors = value; }
        }
    }

Any advice would be greatly appreciated, kind of hit a brick wall with it now

Thanks
Jason
Answers (1)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

In this case you have to implement security logic, the .Net provides an entire API  System.Security, you can create a permission set that determines rule of messages transactions 
0
Riccardo
NA 5 0 16y
I mean every outgoing mail of a company (mail from a internal network to outside the network)
0
Bechir Bejaoui
NA 20.1k 5.3m 16y

What do you mean by outgoing mail, do you mean from example a spam?
0
Riccardo
NA 5 0 16y
Thank you very much for your answer!

Probably I should explain a little bit more about the functionality I would like to implement. Basicaly I would like to check every outgoing mail. Therefore I would like to
1. stop the smtp queue
2. wait for messages
3.check these messages (allowed or unallowed and probably remove some of them)
4. Start the smtp queue, so the messages can be send


0
Bechir Bejaoui
NA 20.1k 5.3m 16y

If I well understand your question you're using a Message queue object then you can do

MessageQueue mqueue = new MessageQueue();
            //This method will make the message queue in a standby state for any message
            IAsyncResult Async = mqueue.BeginReceive();

            //TO do perform you code here

            //This method
            Message Recived = mqueue.EndReceive(Async);
           
            //close the message queue
            mqueue.Close();
It's better to do that asynchormously