Webservice中的SqlException在数据库中使用Text Data Types时

时间:2011-08-11 18:49:45

标签: c# linq-to-sql

我正在ASP.NET中创建一个Web服务。

[WebMethod]
public List<OfferEntity> TopOffers(int limit) {
    BabaDingeDataContext babadinge = new BabaDingeDataContext();
    List<OfferEntity> hotOffers = (
        from h in babadinge.Offers
        orderby h.views
        select new OfferEntity { 
            Name = h.name, 
            Location = h.location,
            Description = h.description,
            Date = h.date,
            Tags = h.tags,
            Image = "",
            Views = h.views,
            Price = h.price,
            URL = ""
        }).ToList();

    return hotOffers;
}

public class OfferEntity
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public string Location { get; set; }
    public DateTime Date { get; set; }
    public string Tags { get; set; }
    public string Image { get; set; }
    public int Views { get; set; }
    public string Price { get; set; }
    public string URL { get; set; }
}

使用webservice时出现以下异常:

  

System.ServiceModel.FaultException未被用户代码
处理   Message = System.Web.Services.Protocols.SoapException:服务器无法使用   处理请求。 ---&GT; System.Data.SqlClient.SqlException:数据   类型nvarchar和text在add运算符中不兼容   在System.Data.SqlClient.SqlConnection.OnError(SqlException异常,   Boolean breakConnection)
  在... ....

好像它不喜欢文本数据类型......有没有解决方法?

0 个答案:

没有答案