本文整理汇总了C#中DomainObject类的典型用法代码示例。如果您正苦于以下问题:C# DomainObject类的具体用法?C# DomainObject怎么用?C# DomainObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DomainObject类属于命名空间,在下文中一共展示了DomainObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: delete
public void delete(DomainObject subject, SqlConnection connection, SqlTransaction transaction)
{
try
{
Person person = (Person)subject;
SqlCommand command = new SqlCommand(
"DELETE FROM Persons WHERE PersonID = @PersonId AND chTimestamp = @chTimestamp",
connection, transaction);
command.Parameters.Add("@chTimestamp", person.Timestamp.Value);
if(subject.isNull("PersonId"))
{
command.Parameters.Add("@PersonId", DBNull.Value );
}
else
{
command.Parameters.Add("@PersonId", person.PersonId);
}
if(command.ExecuteNonQuery() <= 0)
{
throw new ConcurrencyException();
}
}
catch(SqlException sqle)
{
throw new ApplicationException(sqle.Message);
}
catch(Exception e)
{
throw new ApplicationException(e.Message);
}
}
示例2: delete
public void delete(DomainObject subject, SqlConnection connection, SqlTransaction transaction)
{
try
{
Employee employee = (Employee)subject;
SqlCommand command = new SqlCommand(
"DELETE FROM Employees WHERE EmployeeID = @EmployeeId AND VersionId = @VersionId",
connection, transaction);
command.Parameters.Add("@VersionId", employee.Timestamp.Value);
if(subject.isNull("EmployeeId"))
{
command.Parameters.Add("@EmployeeId", DBNull.Value );
}
else
{
command.Parameters.Add("@EmployeeId", employee.EmployeeId);
}
if(command.ExecuteNonQuery() <= 0)
{
throw new ConcurrencyException();
}
}
catch(SqlException sqle)
{
throw new ApplicationException(sqle.Message);
}
catch(Exception e)
{
throw new ApplicationException(e.Message);
}
}
示例3: WithCustomizedTagNameAndIdentityProperty
public void WithCustomizedTagNameAndIdentityProperty()
{
var id = string.Empty;
using (var store = NewDocumentStore())
{
store.Conventions.AllowQueriesOnId = true;
var defaultFindIdentityProperty = store.Conventions.FindIdentityProperty;
store.Conventions.FindIdentityProperty = property =>
typeof(IEntity).IsAssignableFrom(property.DeclaringType)
? property.Name == "Id2"
: defaultFindIdentityProperty(property);
store.Conventions.FindTypeTagName = type =>
typeof (IDomainObject).IsAssignableFrom(type)
? "domainobjects"
: DocumentConvention.DefaultTypeTagName(type);
using (var session = store.OpenSession())
{
var domainObject = new DomainObject();
session.Store(domainObject);
var domainObject2 = new DomainObject();
session.Store(domainObject2);
session.SaveChanges();
id = domainObject.Id2;
}
var matchingDomainObjects = store.OpenSession().Query<IDomainObject>().Where(_ => _.Id2 == id).ToList();
Assert.Equal(matchingDomainObjects.Count, 1);
}
}
示例4: deepCopy
protected override void deepCopy(DomainObject domainObject)
{
base.deepCopy(domainObject);
File file = (File)domainObject;
relFileNamePath = file.relFileNamePath;
}
示例5: delete
public void delete(DomainObject subject, SqlConnection connection, SqlTransaction transaction)
{
try
{
Territory territory = (Territory)subject;
SqlCommand command = new SqlCommand(
"DELETE FROM Territories WHERE TerritoryID = @TerritoryId AND VersionId = @VersionId",
connection, transaction);
command.Parameters.Add("@VersionId", territory.Timestamp.Value);
if(subject.isNull("TerritoryId"))
{
command.Parameters.Add("@TerritoryId", DBNull.Value );
}
else
{
command.Parameters.Add("@TerritoryId", territory.TerritoryId);
}
if(command.ExecuteNonQuery() <= 0)
{
throw new ConcurrencyException();
}
}
catch(SqlException sqle)
{
throw new ApplicationException(sqle.Message);
}
catch(Exception e)
{
throw new ApplicationException(e.Message);
}
}
示例6: SetInfoFieldFromObject
public override void SetInfoFieldFromObject(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
{
Entity entity = (Entity)GetClassFieldValue(pobj);
if (entity != null && pctx.IsProxyLoaded(entity))
{
SetInfoFieldValue(info, _entityConversion.GetInfoFromObject(entity, pctx));
}
}
示例7: unregisterDomainObject
public void unregisterDomainObject(DomainObject domainObject)
{
Hashtable typeMap = (Hashtable)m_typeMaps[domainObject.GetType().BaseType];
if(typeMap == null)
Debug.Assert(false);
Debug.Assert(typeMap.Contains(domainObject.Id));
typeMap.Remove(domainObject.Id);
}
示例8: RegisterDirty
public void RegisterDirty(DomainObject obj)
{
if (!(this.newObjects.Contains(obj) || this.dirtyObjects.Contains(obj)))
{
this.dirtyObjects.Add(obj);
this.OnChanged();
}
}
示例9: IsPersistent
public static bool IsPersistent(DomainObject entity)
{
var keyAttributedProps =
entity.GetType()
.GetProperties()
.FirstOrDefault(p => p.GetCustomAttributes(typeof (KeyAttribute), true).Length == 1);
return (keyAttributedProps != null) && !keyAttributedProps.GetValue(entity, null).ToString().Equals("0");
}
示例10: Remove
public void Remove(DomainObject item)
{
if(item == Person.None) return;
if (_domainObjects.Contains(item) == false) return; // Already exists
IList bindingList = _bindingLists[item.GetType()];
bindingList.Remove(item);
_domainObjects.Remove(item);
}
示例11: Persist
public void Persist(DomainObject<Guid, DomainEvent> entity)
{
foreach (var @event in entity.GetEvents())
{
this.events.Add(@event);
Console.WriteLine("Saved event {0} to the store.", @event);
}
entity.AcceptEvents();
}
示例12: Validate
public override bool Validate(DomainObject domainObject)
{
try
{
return GetPropertyValue(domainObject).ToString().Length > 0;
}
catch
{
return false;
}
}
示例13: SetObjectFieldFromInfo
public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
{
EntityInfo entityInfo = (EntityInfo)GetInfoFieldValue(info);
if (entityInfo != null && entityInfo.GetEntityRef() != null)
{
// don't copy any information from the referenced EntityInfo
// only take its reference
Entity entity = pctx.Load(entityInfo.GetEntityRef(), EntityLoadFlags.Proxy); // proxy, no version check!
SetClassFieldValue(pobj, entity);
}
}
示例14: GetAll
public List<Comment> GetAll(DomainObject<int> target)
{
return DbManager
.ExecuteList(
Query("projects_comments")
.Select(columns)
.Where("target_uniq_id", target.UniqID))
.ConvertAll(r => ToComment(r))
.OrderBy(c => c.CreateOn)
.ToList();
}
示例15: registerDomainObject
public void registerDomainObject(DomainObject domainObject)
{
Type type = domainObject.GetType().BaseType;
Hashtable typeMap = (Hashtable)m_typeMaps[type];
if(typeMap == null)
{
typeMap = new Hashtable();
m_typeMaps[type] = typeMap;
}
Debug.Assert(typeMap.Contains(domainObject) == false);
typeMap.Add(domainObject.Id, domainObject);
}