本文整理汇总了C#中IDataReader.GetStringGetter方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetStringGetter方法的具体用法?C# IDataReader.GetStringGetter怎么用?C# IDataReader.GetStringGetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataReader
的用法示例。
在下文中一共展示了IDataReader.GetStringGetter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>Read in implicit feedback data from an IDataReader, e.g. a database via DbDataReader</summary>
/// <param name="reader">the IDataReader to be read from</param>
/// <param name="user_mapping">user <see cref="IMapping"/> object</param>
/// <param name="item_mapping">item <see cref="IMapping"/> object</param>
/// <returns>a <see cref="IPosOnlyFeedback"/> object with the user-wise collaborative data</returns>
public static IPosOnlyFeedback Read(IDataReader reader, IMapping user_mapping, IMapping item_mapping)
{
var feedback = new PosOnlyFeedback<SparseBooleanMatrix>();
if (reader.FieldCount < 2)
throw new FormatException("Expected at least 2 columns.");
Func<string> get_user_id = reader.GetStringGetter(0);
Func<string> get_item_id = reader.GetStringGetter(1);
while (reader.Read())
{
int user_id = user_mapping.ToInternalID(get_user_id());
int item_id = item_mapping.ToInternalID(get_item_id());
feedback.Add(user_id, item_id);
}
return feedback;
}
示例2: Read
/// <summary>Read in rating data which will be interpreted as implicit feedback data from an IDataReader, e.g. a database via DbDataReader</summary>
/// <param name="reader">the IDataReader to be read from</param>
/// <param name="rating_threshold">the minimum rating value needed to be accepted as positive feedback</param>
/// <param name="user_mapping">user <see cref="IEntityMapping"/> object</param>
/// <param name="item_mapping">item <see cref="IEntityMapping"/> object</param>
/// <returns>a <see cref="IPosOnlyFeedback"/> object with the user-wise collaborative data</returns>
public static IPosOnlyFeedback Read(IDataReader reader, float rating_threshold, IEntityMapping user_mapping, IEntityMapping item_mapping)
{
var feedback = new PosOnlyFeedback<SparseBooleanMatrix>();
if (reader.FieldCount < 3)
throw new FormatException("Expected at least 3 columns.");
Func<string> get_user_id = reader.GetStringGetter(0);
Func<string> get_item_id = reader.GetStringGetter(1);
Func<float> get_rating = reader.GetFloatGetter(2);
while (reader.Read())
{
int user_id = user_mapping.ToInternalID(get_user_id());
int item_id = item_mapping.ToInternalID(get_item_id());
float rating = get_rating();
if (rating >= rating_threshold)
feedback.Add(user_id, item_id);
}
return feedback;
}
示例3: Read
/// <summary>Read in rating data from an IDataReader, e.g. a database via DbDataReader</summary>
/// <param name="reader">the <see cref="IDataReader"/> to read from</param>
/// <param name="user_mapping">mapping object for user IDs</param>
/// <param name="item_mapping">mapping object for item IDs</param>
/// <returns>the rating data</returns>
public static IRatings Read(IDataReader reader, IMapping user_mapping, IMapping item_mapping)
{
var ratings = new Ratings();
if (reader.FieldCount < 3)
throw new FormatException("Expected at least 3 columns.");
Func<string> get_user_id = reader.GetStringGetter(0);
Func<string> get_item_id = reader.GetStringGetter(1);
Func<float> get_rating = reader.GetFloatGetter(2);
while (reader.Read())
{
int user_id = user_mapping.ToInternalID(get_user_id());
int item_id = item_mapping.ToInternalID(get_item_id());
float rating = get_rating();
ratings.Add(user_id, item_id, rating);
}
ratings.InitScale();
return ratings;
}
示例4: Read
/// <summary>Read binary relation data from an IDataReader, e.g. a database via DbDataReader</summary>
/// <param name="reader">an IDataReader to be read from</param>
/// <param name="mapping">the mapping object for the given entity type</param>
/// <returns>the relation data</returns>
static public IBooleanMatrix Read(IDataReader reader, IMapping mapping)
{
if (reader.FieldCount < 2)
throw new FormatException("Expected at least 2 columns.");
var matrix = new SparseBooleanMatrix();
Func<string> get_e1_id = reader.GetStringGetter(0);
Func<string> get_e2_id = reader.GetStringGetter(1);
while (!reader.Read())
{
int entity1_id = mapping.ToInternalID(get_e1_id());
int entity2_id = mapping.ToInternalID(get_e2_id());
matrix[entity1_id, entity2_id] = true;
}
return matrix;
}