Browse Source

Post.mentionedUsersIds optimized

main
Inga 🏳‍🌈 11 years ago
parent
commit
88fa0e7758
  1. 21
      FLocal.Common/dataobjects/Post.cs
  2. 4
      Web.Core/DB/IDBConnection.cs

21
FLocal.Common/dataobjects/Post.cs

@ -391,17 +391,16 @@ namespace FLocal.Common.dataobjects { @@ -391,17 +391,16 @@ namespace FLocal.Common.dataobjects {
private IEnumerable<int> mentionedUsersIds {
get {
return from mention in Mention.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Mention.TableSpec.instance,
new ComparisonCondition(
Mention.TableSpec.instance.getColumnSpec(Mention.TableSpec.FIELD_POSTID),
ComparisonType.EQUAL,
this.id.ToString()
),
Diapasone.unlimited
) select int.Parse(stringId)
) select mention.mentionedUserId;
return from stringId in Config.instance.mainConnection.LoadIdsByConditions(
Mention.TableSpec.instance,
new ComparisonCondition(
Mention.TableSpec.instance.getColumnSpec(Mention.TableSpec.FIELD_POSTID),
ComparisonType.EQUAL,
this.id.ToString()
),
Diapasone.unlimited,
Mention.TableSpec.instance.getColumnSpec(Mention.TableSpec.FIELD_MENTIONEDUSERID)
) select int.Parse(stringId);
}
}

4
Web.Core/DB/IDBConnection.cs

@ -41,6 +41,10 @@ namespace Web.Core.DB { @@ -41,6 +41,10 @@ namespace Web.Core.DB {
return connection.LoadIdsByConditions(table, conditions, diapasone, joins, new SortSpec[] { new SortSpec(table.getIdSpec(), true) });
}
public static List<string> LoadIdsByConditions(this IDBConnection connection, ITableSpec table, AbstractCondition conditions, Diapasone diapasone, ColumnSpec idSpec, params SortSpec[] sorts) {
return connection.LoadIdsByConditions(table, conditions, diapasone, new JoinSpec[0], sorts, idSpec, false);
}
public static Transaction beginTransaction(this IDBConnection connection) {
return connection.beginTransaction(System.Data.IsolationLevel.ReadCommitted);
}

Loading…
Cancel
Save