本文整理汇总了C#中IEntity.get方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.get方法的具体用法?C# IEntity.get怎么用?C# IEntity.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetParameters
internal static void SetParameters( IDbCommand cmd, String action, IEntity obj, EntityInfo entityInfo )
{
for (int i = 0; i < entityInfo.SavedPropertyList.Count; i++) {
EntityPropertyInfo info = entityInfo.SavedPropertyList[i];
if (isContinue( action, info, entityInfo )) continue;
Object paramVal = obj.get( info.Name );
if (paramVal == null && info.DefaultAttribute != null) {
paramVal = info.DefaultAttribute.Value;
}
if (paramVal == null) {
setDefaultValue( cmd, info, entityInfo );
}
else if (info.Type.IsSubclassOf( typeof( IEntity ) ) || MappingClass.Instance.ClassList.Contains( info.Type.FullName )) {
setEntityId( cmd, info, paramVal );
}
else {
paramVal = DataFactory.SetParameter( cmd, info.ColumnName, paramVal );
obj.set( info.Name, paramVal );
}
}
}
示例2: Validate
public static Result Validate(IEntity target, String action)
{
EntityInfo entityInfo = Entity.GetInfo(target);
Result result = new Result();
try
{
foreach (EntityPropertyInfo info in entityInfo.SavedPropertyList)
{
if (!info.SaveToDB) continue;
if (checkLength(info))
{
Object val = target.get(info.Name);
if (val != null)
target.set(info.Name, strUtil.SubString(val.ToString(), info.SaveAttribute.Length));
}
foreach (ValidationAttribute vattr in info.ValidationAttributes)
{
vattr.Validate(action, target, info.Name, result);
}
}
}
catch (Exception ex)
{
LogManager.GetLogger(typeof(Validator)).Error(ex.Message);
}
return result;
}
示例3: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
{
Object obj = target.get( info.Name );
Boolean isNull = false;
if (info.Type == typeof( String )) {
if (obj == null) {
isNull = true;
}
else if (strUtil.IsNullOrEmpty( obj.ToString() )) {
isNull = true;
}
}
else if (obj == null) {
isNull = true;
}
if (isNull) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
EntityInfo ei = Entity.GetInfo( target );
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + "can not be null" );
}
}
}
示例4: Insert
private static Result Insert( IEntity obj, EntityInfo entityInfo, Boolean isInsertParent ) {
Result result = Validator.Validate( obj, "insert" );
if (result.HasErrors) return result;
if (isInsertParent && entityInfo.Parent != null) {
IEntity objP = Entity.New( entityInfo.Type.BaseType.FullName );
List<EntityPropertyInfo> eplist = Entity.GetInfo( objP ).SavedPropertyList;
foreach (EntityPropertyInfo info in eplist) {
if (info.IsList) continue;
objP.set( info.Name, obj.get( info.Name ) );
}
ObjectDb.Insert( objP );
obj.Id = objP.Id;
}
List<IInterceptor> ilist = MappingClass.Instance.InterceptorList;
for (int i = 0; i < ilist.Count; i++) {
ilist[i].BeforInsert( obj );
}
var conn = DbContext.getConnection(entityInfo);
if (conn.State == System.Data.ConnectionState.Closed)
{
conn.Open();
OrmHelper.initCount++;
LogManager.GetLogger("Class:System.Data.InsertOperation Method:Insert").Info("数据库连接已开启【" + OrmHelper.initCount + "】");
}
IDbCommand cmd = DataFactory.GetCommand(getInsertSql(entityInfo), conn);
OrmHelper.SetParameters(cmd, "insert", obj, entityInfo);
obj.Id = executeCmd(cmd, entityInfo);
if (!DbContext.shouldTransaction())
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
conn.Dispose();
OrmHelper.clostCount++;
LogManager.GetLogger("Class:System.ORM.Operation.InsertOperation Method:Insert").Info("数据库连接已关闭【" + OrmHelper.clostCount + "】");
}
}
for (int i = 0; i < ilist.Count; i++) {
ilist[i].AfterInsert( obj );
}
CacheUtil.CheckCountCache( "insert", obj, entityInfo );
result.Info = obj;
CacheTime.updateTable( obj.GetType() );
return result;
}
示例5: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
{
if (!Regex.IsMatch( cvt.ToNotNull( target.get( info.Name ) ), this.Regexp, RegexOptions.Singleline )) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
EntityInfo ei = Entity.GetInfo( target );
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + " is not match the format pattern : " + this.Regexp );
}
}
}
示例6: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result ) {
Object obj = target.get( info.Name );
EntityInfo ei = Entity.GetInfo( target );
int count = getCount( action, target, ei, info, obj );
if (count > 0) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + " should be unique, but it has been in database" );
}
}
}
示例7: Update
public static void Update( IEntity obj, String[] arrPropertyName, EntityInfo entityInfo )
{
if (obj == null) throw new ArgumentNullException();
StringBuilder builder = new StringBuilder( String.Empty );
builder.Append( "update " );
builder.Append( entityInfo.TableName );
builder.Append( " set " );
for (int i = 0; i < arrPropertyName.Length; i++) {
String columnName = entityInfo.GetColumnName( arrPropertyName[i] );
builder.Append( columnName );
builder.Append( "=" );
builder.Append( entityInfo.Dialect.GetParameter( columnName ) );
builder.Append( "," );
}
builder.Append( " where Id=" );
builder.Append( entityInfo.Dialect.GetParameter( "Id" ) );
String commandText = builder.ToString().Replace( ", where", " where" );
logger.Info( LoggerUtil.SqlPrefix+entityInfo.Name + "[" + entityInfo.TableName + "] Update Sql:" + commandText );
List<IInterceptor> ilist = MappingClass.Instance.InterceptorList;
for (int i = 0; i < ilist.Count; i++) {
ilist[i].BeforUpdate( obj );
}
IDbCommand cmd = DataFactory.GetCommand( commandText, DbContext.getConnection( entityInfo ) );
for (int i = 0; i < arrPropertyName.Length; i++) {
Object parameterValue = obj.get( arrPropertyName[i] );
String columnName = entityInfo.GetColumnName( arrPropertyName[i] );
DataFactory.SetParameter( cmd, columnName, parameterValue );
}
int id = obj.Id;
DataFactory.SetParameter( cmd, "Id", id );
cmd.ExecuteNonQuery();
for (int i = 0; i < ilist.Count; i++) {
ilist[i].AfterUpdate( obj );
}
// update cache timestamp
CacheTime.updateTable( entityInfo.Type );
CacheUtil.CheckCountCache( "insert", obj, entityInfo );
}
示例8: Validate
public static Result Validate( IEntity target, String action )
{
EntityInfo entityInfo = Entity.GetInfo( target );
Result result = new Result();
foreach (EntityPropertyInfo info in entityInfo.SavedPropertyList) {
if (!info.SaveToDB) continue;
if (checkLength(info)) {
Object val = target.get( info.Name );
if( val != null )
target.set( info.Name, strUtil.SubString( val.ToString(), info.SaveAttribute.Length ) );
}
foreach (ValidationAttribute vattr in info.ValidationAttributes) {
vattr.Validate( action, target, info.Name, result );
}
}
return result;
}
示例9: setParentValueFromChild
private static void setParentValueFromChild( IEntity objParent, IEntity objChild )
{
List<EntityPropertyInfo> eplist = Entity.GetInfo( objParent ).SavedPropertyList;
foreach (EntityPropertyInfo info in eplist) {
objParent.set( info.Name, objChild.get( info.Name ) );
}
}
示例10: getPropertyValue
private string getPropertyValue( IEntity data, EntityInfo ei, String propertyName )
{
if (ei.GetProperty( propertyName ) == null) return "";
Object summary = data.get( propertyName );
return summary == null ? "" : summary.ToString();
}
示例11: setRow
private void setRow( EntityInfo ei, StringBuilder sb, IEntity o ) {
sb.Append( "<tr>" );
sb.AppendFormat( "<td class=\"tdOID\">{0}</td>", o.Id );
foreach (EntityPropertyInfo info in ei.SavedPropertyList) {
if (info.Name.Equals( "Id" )) continue;
object pvalue = o.get( info.Name );
if (info.IsEntity) {
pvalue = this.getEntityPropertyName( info, pvalue );
}
else if (info.IsLongText) {
pvalue = strUtil.ParseHtml( pvalue, 20 ) + "...";
}
sb.AppendFormat( "<td>{0} </td>", pvalue );
}
sb.AppendFormat( "<td class=\"tdOperation\"><a href=\"{0}\">修改</a> <a href=\"{1}\" class=\"deleteCmd\">删除</a></td>", to( Edit, o.Id ) + "?typeName=" + ei.FullName, to( Delete, o.Id ) + "?typeName=" + ei.FullName );
sb.Append( "</tr>" );
}
示例12: renewEntityPropertyValue
private void renewEntityPropertyValue( IEntity obj )
{
EntityInfo ei = Entity.GetInfo( obj );
foreach (EntityPropertyInfo ep in ei.EntityPropertyList) {
IEntity objP = obj.get( ep.Name ) as IEntity;
if (objP == null) continue;
IEntity val = this.findOnePrivate( objP.GetType(), objP.Id );
if (val == null) continue;
ep.SetValue( obj, val );
}
}
示例13: setEntityProperty
private static IEntity setEntityProperty( IEntity obj, long id, ObjectInfo state )
{
if (obj == null)
return null;
IList entityPropertyList = state.EntityInfo.EntityPropertyList;
foreach (EntityPropertyInfo ep in entityPropertyList) {
if (!isPropertyInIncluder( ep, state.Includer.EntityPropertyList )) continue;
IEntity propertyValue = obj.get( ep.Name ) as IEntity;
if (propertyValue == null) continue;
long pid = propertyValue.Id;
if (pid <= 0) continue;
IEntity cachedValue = ObjectPool.FindOne( ep.Type, pid );
if (cachedValue == null) {
propertyValue = ObjectDB.FindById( pid, new ObjectInfo( ep.Type ) );
ObjectPool.Add( propertyValue );
}
else {
propertyValue = cachedValue;
}
ValueSetter.setEntityByCheckNull( obj, ep, propertyValue, pid );
}
return obj;
}
示例14: showEdit
private void showEdit( IEntity obj ) {
EntityInfo entityInfo = Entity.GetInfo( obj );
Html html = new Html();
html.Code( "<form methond=\"post\" class=\"ajaxPostForm\" action=\"" + to( Update, obj.Id ) + "\">" );
html.Code( string.Format( "<div class='codeCmd'><a href='{0}'>返回列表</a></div>", to( Model ) + "?typeName=" + entityInfo.FullName ) );
html.Code( "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" class='formTable'>" );
foreach (EntityPropertyInfo pInfo in entityInfo.SavedPropertyList) {
if (pInfo.Name.Equals( "Id" )) continue;
string str = this.getPropertyValue( obj, pInfo );
string style = "";
if ((pInfo.SaveAttribute == null) || ((pInfo.SaveAttribute != null) && (pInfo.SaveAttribute.Length > 100))) {
style = "width:400px;";
}
string control = Html.TextInput( pInfo.Name, str, style );
if (pInfo.IsLongText) {
if (rft.GetAttribute( pInfo.Property, typeof( HtmlTextAttribute ) ) != null) {
String itemName = pInfo.Name;
control = @"<script type=""text/plain"" id=""" + itemName + @""" name=""" + itemName + @""">" + str + @"</script>
<script>
_run(function () {
wojilu.editor.bind('" + itemName + @"').height(220).line(2).show();
});
</script>
";
}
else {
control = "<div>" + Html.TextArea( pInfo.Name, str, "width:98%; height:80px;" ) + "</div>";
}
}
else if (pInfo.IsEntity) {
string textField = getDropText( pInfo );
if (textField.Length > 0) {
IList list = ndb.findAll( pInfo.Type );
if (list.Count > 0) {
IEntity objP = obj.get( pInfo.Name ) as IEntity;
if (objP != null) {
control = Html.DropList( list, pInfo.Name, textField, "Id", objP.Id );
}
}
}
}
html.Code( string.Format( "<tr><td class=\"mLable\">{0}</td><td>{1} {2}</td></tr>", pInfo.Label, control, this.getErrorInfo( pInfo.Name ) ) );
}
html.Code( "</td></tr></table>" );
html.Code( "<div style=\"margin:5px 10px;\">" );
html.Submit( "修改数据" );
html.Code( "<input type=\"button\" onclick=\"history.back();\" value=\"返回\" style=\"margin-left:15px;\" />" );
html.HiddenInput( "typeName", entityInfo.FullName );
html.Code( "</div>" );
html.FormEnd();
actionContent( html.ToString() );
}
示例15: Update
public static void Update( IEntity obj, String[] arrPropertyName, EntityInfo entityInfo ) {
if (obj == null) throw new ArgumentNullException();
StringBuilder builder = new StringBuilder( String.Empty );
builder.Append( "update " );
builder.Append( entityInfo.TableName );
builder.Append( " set " );
for (int i = 0; i < arrPropertyName.Length; i++)
{
String columnName = entityInfo.GetColumnName(arrPropertyName[i]);
builder.Append(columnName);
builder.Append("=");
builder.Append(entityInfo.Dialect.GetParameter(columnName));
builder.Append(",");
}
builder.Append( " where Id=" );
builder.Append( entityInfo.Dialect.GetParameter( "Id" ) );
String commandText = builder.ToString().Replace( ", where", " where" );
logger.Info( LoggerUtil.SqlPrefix+entityInfo.Name + "[" + entityInfo.TableName + "] Update Sql:" + commandText );
List<IInterceptor> ilist = MappingClass.Instance.InterceptorList;
for (int i = 0; i < ilist.Count; i++) {
ilist[i].BeforUpdate( obj );
}
var conn = DbContext.getConnection(entityInfo);
if (conn.State == System.Data.ConnectionState.Closed)
{
conn.Open();
OrmHelper.initCount++;
LogManager.GetLogger("Class:System.ORM.Operation.UpdateOperation Method:Update").Info("数据库连接已开启【" + OrmHelper.initCount + "】");
}
IDbCommand cmd = DataFactory.GetCommand(commandText, conn);
for (int i = 0; i < arrPropertyName.Length; i++)
{
Object parameterValue = obj.get(arrPropertyName[i]);
String columnName = entityInfo.GetColumnName(arrPropertyName[i]);
DataFactory.SetParameter(cmd, columnName, parameterValue);
}
int id = obj.Id;
DataFactory.SetParameter(cmd, "Id", id);
cmd.ExecuteNonQuery();
if (!DbContext.shouldTransaction())
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
conn.Dispose();
OrmHelper.clostCount++;
LogManager.GetLogger("Class:System.ORM.Operation.UpdateOperation Method:Update").Info("数据库连接已关闭【" + OrmHelper.clostCount + "】");
}
}
for (int i = 0; i < ilist.Count; i++) {
ilist[i].AfterUpdate( obj );
}
// update cache timestamp
CacheTime.updateTable( entityInfo.Type );
CacheUtil.CheckCountCache( "insert", obj, entityInfo );
}