本文整理汇总了C#中IMapping类的典型用法代码示例。如果您正苦于以下问题:C# IMapping类的具体用法?C# IMapping怎么用?C# IMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMapping类属于命名空间,在下文中一共展示了IMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DemoService
public DemoService(IRepository<DemoEntity> demoRepository,
IEventPublisher eventPublisher,IMapping mapping)
{
_demoRepository = demoRepository;
_eventPublisher = eventPublisher;
_mapping = mapping;
}
示例2: SqlTypes
public override SqlType[] SqlTypes(IMapping mapping)
{
if (compression == null)
return new SqlType[] { new StringClobSqlType() };
else
return new SqlType[] { new BinaryBlobSqlType() };
}
示例3: GetAliasedLHSColumnNames
/// <summary>
/// Get the aliased columns of the owning entity which are to
/// be used in the join
/// </summary>
public static string[] GetAliasedLHSColumnNames(
IAssociationType type,
string alias,
int property,
int begin,
IOuterJoinLoadable lhsPersister,
IMapping mapping
)
{
if (type.UseLHSPrimaryKey)
{
return StringHelper.Qualify(alias, lhsPersister.IdentifierColumnNames);
}
else
{
string propertyName = type.LHSPropertyName;
if (propertyName == null)
{
return ArrayHelper.Slice(
lhsPersister.ToColumns(alias, property),
begin,
type.GetColumnSpan(mapping)
);
}
else
{
return ((IPropertyMapping) lhsPersister).ToColumns(alias, propertyName); //bad cast
}
}
}
示例4: Read
/// <summary>Read in rating data from a TextReader</summary>
/// <param name="reader">the <see cref="TextReader"/> 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 ITimedRatings Read(TextReader reader, IMapping user_mapping = null, IMapping item_mapping = null)
{
if (user_mapping == null)
user_mapping = new IdentityMapping();
if (item_mapping == null)
item_mapping = new IdentityMapping();
var ratings = new TimedRatings();
string[] separators = { "::" };
string line;
while ((line = reader.ReadLine()) != null)
{
string[] tokens = line.Split(separators, StringSplitOptions.None);
if (tokens.Length < 4)
throw new FormatException(string.Format("Expected at least 4 columns: {0}", line));
int user_id = user_mapping.ToInternalID(tokens[0]);
int item_id = item_mapping.ToInternalID(tokens[1]);
float rating = float.Parse(tokens[2], CultureInfo.InvariantCulture);
long seconds = uint.Parse(tokens[3]);
var time = new DateTime(seconds * 10000000L).AddYears(1969);
var offset = TimeZone.CurrentTimeZone.GetUtcOffset(time);
time -= offset;
ratings.Add(user_id, item_id, rating, time);
}
return ratings;
}
示例5: SqlTriggerBody
public override string SqlTriggerBody(
Dialect dialect, IMapping p,
string defaultCatalog, string defaultSchema)
{
var auditTableName = dialect.QuoteForTableName(_auditTableName);
var eDialect = (IExtendedDialect)dialect;
string triggerSource = _action == TriggerActions.DELETE ?
eDialect.GetTriggerOldDataAlias() :
eDialect.GetTriggerNewDataAlias();
var columns = new List<string>(_dataColumnNames);
columns.AddRange(from ac in _auditColumns
select ac.Name);
var values = new List<string>();
values.AddRange(
from columnName in _dataColumnNames
select eDialect.QualifyColumn(
triggerSource, columnName));
values.AddRange(
from auditColumn in _auditColumns
select auditColumn.ValueFunction.Invoke(_action));
return eDialect.GetInsertIntoString(auditTableName,
columns, triggerSource, values);
}
示例6: Read
/// <summary>Read binary attribute data from a file</summary>
/// <remarks>
/// The expected (sparse) line format is:
/// ENTITY_ID tab/space/comma ATTRIBUTE_ID
/// for the relations that hold.
/// </remarks>
/// <param name="filename">the name of the file to be read from</param>
/// <param name="mapping">the mapping object for the given entity type</param>
/// <returns>the attribute data</returns>
static public IBooleanMatrix Read(string filename, IMapping mapping)
{
return Wrap.FormatException<IBooleanMatrix>(filename, delegate() {
using ( var reader = new StreamReader(filename) )
return Read(reader, mapping);
});
}
示例7: CompositeElementPropertyMapping
public CompositeElementPropertyMapping(string[] elementColumns, string[] elementFormulaTemplates,
IAbstractComponentType compositeType, IMapping factory)
{
this.compositeType = compositeType;
InitComponentPropertyPaths(null, compositeType, elementColumns, elementFormulaTemplates, factory);
}
示例8: Read
/// <summary>Read in rating data from a TextReader</summary>
/// <param name="reader">the <see cref="TextReader"/> to read from</param>
/// <param name="user_mapping">mapping object for user IDs</param>
/// <param name="item_mapping">mapping object for item IDs</param>
/// <param name="ignore_first_line">if true, ignore the first line</param>
/// <returns>the rating data</returns>
public static IRatings Read(TextReader reader, IMapping user_mapping = null, IMapping item_mapping = null, bool ignore_first_line = false)
{
if (user_mapping == null)
user_mapping = new IdentityMapping();
if (item_mapping == null)
item_mapping = new IdentityMapping();
if (ignore_first_line)
reader.ReadLine();
var ratings = new Ratings();
string line;
while ( (line = reader.ReadLine()) != null )
{
if (line.Length == 0)
continue;
string[] tokens = line.Split(Constants.SPLIT_CHARS);
if (tokens.Length < 3)
throw new FormatException("Expected at least 3 columns: " + line);
int user_id = user_mapping.ToInternalID(tokens[0]);
int item_id = item_mapping.ToInternalID(tokens[1]);
float rating = float.Parse(tokens[2], CultureInfo.InvariantCulture);
ratings.Add(user_id, item_id, rating);
}
ratings.InitScale();
return ratings;
}
示例9: SqlCreateString
public override string SqlCreateString(Dialect dialect,
IMapping p, string defaultCatalog, string defaultSchema)
{
FinalizeAuditTable((IExtendedDialect) dialect);
return auditTable.SqlCreateString(
dialect, p, defaultCatalog, defaultSchema);
}
示例10: Read
/// <summary>Read in rating data which will be interpreted as implicit feedback data from a TextReader</summary>
/// <param name="reader">the TextReader 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="IMapping"/> object</param>
/// <param name="item_mapping">item <see cref="IMapping"/> object</param>
/// <param name="ignore_first_line">if true, ignore the first line</param>
/// <returns>a <see cref="IPosOnlyFeedback"/> object with the user-wise collaborative data</returns>
static public IPosOnlyFeedback Read(TextReader reader, float rating_threshold, IMapping user_mapping = null, IMapping item_mapping = null, bool ignore_first_line = false)
{
if (user_mapping == null)
user_mapping = new IdentityMapping();
if (item_mapping == null)
item_mapping = new IdentityMapping();
if (ignore_first_line)
reader.ReadLine();
var feedback = new PosOnlyFeedback<SparseBooleanMatrix>();
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Trim().Length == 0)
continue;
string[] tokens = line.Split(Constants.SPLIT_CHARS);
if (tokens.Length < 3)
throw new FormatException("Expected at least 3 columns: " + line);
int user_id = user_mapping.ToInternalID(tokens[0]);
int item_id = item_mapping.ToInternalID(tokens[1]);
float rating = float.Parse(tokens[2], CultureInfo.InvariantCulture);
if (rating >= rating_threshold)
feedback.Add(user_id, item_id);
}
return feedback;
}
示例11: Register
internal void Register(IMapping mapping)
{
if (!_mappings.ContainsKey(mapping.InterfaceType))
_mappings[mapping.InterfaceType] = new Collection<IMapping>();
_mappings[mapping.InterfaceType].Add(mapping);
}
示例12: Read
/// <summary>Read in static rating data from a file</summary>
/// <param name="filename">the name of the file to read from</param>
/// <param name="user_mapping">mapping object for user IDs</param>
/// <param name="item_mapping">mapping object for item IDs</param>
/// <param name="rating_type">the data type to be used for storing the ratings</param>
/// <param name="ignore_first_line">if true, ignore the first line</param>
/// <returns>the rating data</returns>
public static IRatings Read(
string filename,
IMapping user_mapping = null, IMapping item_mapping = null,
RatingType rating_type = RatingType.FLOAT,
bool ignore_first_line = false)
{
string binary_filename = filename + ".bin.StaticRatings";
if (FileSerializer.Should(user_mapping, item_mapping) && File.Exists(binary_filename))
return (IRatings) FileSerializer.Deserialize(binary_filename);
int size = 0;
using ( var reader = new StreamReader(filename) )
while (reader.ReadLine() != null)
size++;
if (ignore_first_line)
size--;
return Wrap.FormatException<IRatings>(filename, delegate() {
using ( var reader = new StreamReader(filename) )
{
var ratings = (StaticRatings) Read(reader, size, user_mapping, item_mapping, rating_type);
if (FileSerializer.Should(user_mapping, item_mapping) && FileSerializer.CanWrite(binary_filename))
ratings.Serialize(binary_filename);
return ratings;
}
});
}
示例13: Create
/// <summary>
/// Creates a specific Persister - could be a built in or custom persister.
/// </summary>
public static IEntityPersister Create(System.Type persisterClass, PersistentClass model,
ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory,
IMapping cfg)
{
ConstructorInfo pc;
try
{
pc = persisterClass.GetConstructor(PersisterConstructorArgs);
}
catch (Exception e)
{
throw new MappingException("Could not get constructor for " + persisterClass.Name, e);
}
try
{
return (IEntityPersister) pc.Invoke(new object[] {model, cache, factory, cfg});
}
catch (TargetInvocationException tie)
{
Exception e = tie.InnerException;
if (e is HibernateException)
{
throw e;
}
else
{
throw new MappingException("Could not instantiate persister " + persisterClass.Name, e);
}
}
catch (Exception e)
{
throw new MappingException("Could not instantiate persister " + persisterClass.Name, e);
}
}
示例14: ReturnType
public override IType ReturnType(IType columnType, IMapping mapping)
{
if (columnType == null)
{
throw new ArgumentNullException("columnType");
}
SqlType[] sqlTypes;
try
{
sqlTypes = columnType.SqlTypes(mapping);
}
catch (MappingException me)
{
throw new QueryException(me);
}
if (sqlTypes.Length != 1)
{
throw new QueryException("multi-column type can not be in avg()");
}
SqlType sqlType = sqlTypes[0];
if (sqlType.DbType == DbType.Int16 || sqlType.DbType == DbType.Int32 || sqlType.DbType == DbType.Int64)
{
return NHibernateUtil.Single;
}
else
{
return columnType;
}
}
示例15: SqlCreateString
public override string SqlCreateString(
Dialect.Dialect dialect,
IMapping p,
string defaultSchema)
{
return InjectCatalogAndSchema(sqlCreateString, defaultSchema);
}