How to Write a WCF service method which should accept the logs as a collection in C# ? My WCF service should accept the collection of log messages and then we have to insert into the DB.
Thanks !!!
How to Write a WCF service method which should accept the logs as a collection in C# ? My WCF service should accept the collection of log messages and then we have to insert into the DB.
Thanks !!!
You can implement that simply as follows: ( you might add yourself any other parameters you want to the service method including service headers)
[DataContract]
public class LogData
{
[DataMember]
public long LogId { get; set; }
[DataMember]
public string LogMessage { get; set; }
}
[ServiceContract]
public interface ILoggerService
{
[OperationContract]
void SaveLogs(List<LogData> logs);
}
public class LoggerService : ILoggerService
{
public void SaveLogs(List<LogData> logs)
{
// write your DB specific logic to loop through the logs object and store into the db.
}
}