[英]Azure Mobile Service getting error - Sequence contains no matching element
I have simple Azure Mobile Service
which is connected to MySql Database
我有连接到
MySql Database
简单Azure Mobile Service
Web.Config
<connectionStrings>
<add name="MS_TableConnectionString" connectionString="Server=11.11.111.111;User Id=test;Password=test;Database=testDB" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
App_Start\\WebApiConfig.cs
public static class WebApiConfig
{
public static void Register()
{
ConfigOptions options = new ConfigOptions();
HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
}
}
Controllers\\CommentController.cs
public class CommentController : TableController<wp_comments>
{
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
MobileServiceContext context = new MobileServiceContext();
DomainManager = new EntityDomainManager<wp_comments>(context, Request, Services);
}
// GET tables/Comment
public IQueryable<wp_comments> GetAllComment()
{
return Query(); // Getting Exception Here
}
DataObjects\\wp_comments.cs
public class wp_comments : EntityData
{
public int comment_ID { get; set; }
public int comment_post_ID { get; set; }
[Column("comment_author", TypeName = "NVARCHAR(MAX)")]
public string comment_author { get; set; }
[Column("comment_author_email", TypeName = "NVARCHAR(MAX)")]
public string comment_author_email { get; set; }
[Column("comment_author_url", TypeName = "NVARCHAR(MAX)")]
public string comment_author_url { get; set; }
[Column("comment_author_IP", TypeName = "NVARCHAR(MAX)")]
public string comment_author_IP { get; set; }
public DateTime comment_date { get; set; }
public DateTime comment_date_gmt { get; set; }
[Column("comment_author_IP", TypeName = "NVARCHAR(MAX)")]
public string comment_content { get; set; }
public int comment_karma { get; set; }
[Column("comment_approved", TypeName = "NVARCHAR(MAX)")]
public string comment_approved { get; set; }
[Column("comment_agent", TypeName = "NVARCHAR(MAX)")]
public string comment_agent { get; set; }
[Column("comment_type", TypeName = "NVARCHAR(MAX)")]
public string comment_type { get; set; }
public int comment_parent { get; set; }
public int user_id { get; set; }
}
Models\\MobileServiceContext.cs
public class MobileServiceContext : DbContext
{
private const string connectionStringName = "Name=MS_TableConnectionString";
public MobileServiceContext() : base(connectionStringName)
{
}
public DbSet<wp_comments> Comments { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
string schema = ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
//modelBuilder.Conventions.Add(
// new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
// "ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString()));
}
}
Please check with your model, you have defined the same property "comment_author_IP". 请检查您的模型,是否定义了相同的属性“ comment_author_IP”。 Please modify it then to see whether your code works.
请先对其进行修改,以查看您的代码是否有效。
[Column("comment_author_IP", TypeName = "NVARCHAR(MAX)")]
public string comment_author_IP { get; set; }
public DateTime comment_date { get; set; }
public DateTime comment_date_gmt { get; set; }
[Column("comment_author_IP", TypeName = "NVARCHAR(MAX)")]
public string comment_content { get; set; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.