Closed Maarten88 closed 10 years ago
Can you show me generated sql? Also are you sure you're disposing the connection every time?
That is not so easy. This happens on a production server and we are rolling out a fix that does the same using QuerySingle(sql, params). Database is SQL Azure btw
SqlFu doesn't support Azure, I mean it generates T-SQl but it doesn't take Azure into consideration. Anyway, I'm interested if your fix is working i.e you're skipping the expression generated sql right?
We got the generated sql:
select [Name],[PoolOwnerId],[Announcement],[PoolType],[Id], from [Pool] where ([Id] = @0)
It has a comma to much in it.
And the poco:
[Table("Pool", PrimaryKey = "Id", AutoGenerated = true, CreationOptions = IfTableExists.Ignore)]
[Index("Name", Name = "ix_PoolName", IsUnique = true)]
public class Pool : Entity<int>
{
[Required(ErrorMessage = "Dit is een verplicht veld")]
[ColumnOptions(IsNullable = false, Size = "50")]
public string Name { get; set; }
[ForeignKey("Player", "Id", OnDelete = ForeignKeyRelationCascade.NoAction)]
public int PoolOwnerId { get; set; }
[QueryOnly]
[ColumnOptions(Ignore = true)]
public List<Player> Players { get; set; }
[QueryOnly]
[ColumnOptions(Ignore = true)]
public int PlayerCount { get; set; }
[ColumnOptions(IsNullable=true)]
public string Announcement { get; set; }
[ColumnOptions(DefaultValue = "0")]
public PoolType PoolType { get; set; }
}
public abstract class Entity<TKey> : Entity
{
public Entity(TKey id)
{
this.Id = id;
}
public Entity()
{
}
public TKey Id { get; set; }
}
That's interesting. So, the sql is correctly generated when invoked once, but fails if called 50 times. I've created a test with your data and sql is generated ok. I'll do more digging
We experience strange errors in SqlFu in a web api service that is under substantial load. Some of our most simple queries, generated from lambda expressions, generate syntax errors in SQL Server when called under load. They work by themselves, but calling them quickly 50 times will give the error
The query looks like this:
The stacktrace: