本文整理汇总了C#中Common.DomRepository类的典型用法代码示例。如果您正苦于以下问题:C# Common.DomRepository类的具体用法?C# Common.DomRepository怎么用?C# Common.DomRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Common.DomRepository类属于命名空间,在下文中一共展示了Common.DomRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CascadeDelete
public void CascadeDelete()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var pid1 = Guid.NewGuid();
var pid2 = Guid.NewGuid();
var pid3 = Guid.NewGuid();
var cid11 = Guid.NewGuid();
var cid12 = Guid.NewGuid();
var cid21 = Guid.NewGuid();
var cid31 = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM TestEntity.Child",
"DELETE FROM TestEntity.BaseEntity",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid1 + "', '1'",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid2+ "', '2'",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid3 + "', '3'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid11 + "', '11', '" + pid1 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid12 + "', '12', '" + pid1 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid21 + "', '21', '" + pid2 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid31 + "', '31', '" + pid3 + "'",
});
Assert.AreEqual("11, 12, 21, 31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));
repository.TestEntity.BaseEntity.Delete(new [] { new TestEntity.BaseEntity { ID = pid1 }, new TestEntity.BaseEntity { ID = pid2 } });
Assert.AreEqual("31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:34,代码来源:EntityTest.cs
示例2: NullReference
public void NullReference()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
Guid refID = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM TestBrowse.Source;",
"DELETE FROM TestBrowse.Other;",
"INSERT INTO TestBrowse.Other (ID, Name) SELECT '" + refID + "', 'abc';",
"INSERT INTO TestBrowse.Source (RefID) SELECT NULL;"
});
Assert.IsNull(repository.TestBrowse.Source.Query().ToArray().Select(item => item.Ref != null ? item.Ref.Name : null).Single(), "separated loading with null checking");
Assert.IsNull(repository.TestBrowse.Source.Query().Select(item => item.Ref != null ? item.Ref.Name : null).Single(), "all in one query with null checking");
Assert.IsNull(repository.TestBrowse.Source.Query().Select(item => item.Ref.Name).Single(), "all in one query");
// TODO: "'Separated loading' fails because LINQ2NH will handle nullable properies and null values differently than a simple LINQ query over materialized instances (Linq2Objects). Try to implement browse in a such way that it behaves the same in both scenarios without degrading performance (maybe generating SqlView).
Assert.IsNull(repository.TestBrowse.Source.Query().ToArray().Select(item => item.Ref.Name).Single(), "separated loading");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:25,代码来源:BrowseTest.cs
示例3: DeleteModifiedPersistentObject
public void DeleteModifiedPersistentObject()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
{
var s3Lock = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s3_lock" };
repository.TestLockItems.Simple.Insert(new[] { s3Lock });
AssertData("s3_lock", repository);
executionContext.NHibernateSession.Clear();
AssertData("s3_lock", repository);
}
{
var s3Persistent = repository.TestLockItems.Simple.All().Single();
s3Persistent.Name = "abc";
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Delete(new[] { s3Persistent }),
"Name contains lock mark");
AssertData("s3_lock", repository);
executionContext.NHibernateSession.Clear();
AssertData("s3_lock", repository);
}
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:28,代码来源:LockItemsTest.cs
示例4: ComputeForNewBaseItems
public void ComputeForNewBaseItems()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var d1ID = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM Test9.Document;",
"DELETE FROM Test9.DocumentCreationInfo;",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'"
});
Assert.AreEqual("", ReportDocumentCreationInfo(repository), "initial");
repository.Test9.DocumentCreationInfo.Recompute();
Assert.AreEqual("d1:1", ReportDocumentCreationInfo(repository), "initial recalc");
var documents = repository.Test9.Document;
var d2ID = Guid.NewGuid();
documents.Insert(new[] { new Test9.Document { ID = d2ID, Name = "d2" } });
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "autorecompute after new");
var d3ID = Guid.NewGuid();
var d4ID = Guid.NewGuid();
documents.Insert(new[] { new Test9.Document { ID = d3ID, Name = "d3" }, new Test9.Document { ID = d4ID, Name = "d4" } });
Assert.AreEqual("d1:1, d2:2, d3:4, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after new2");
documents.Save(null, new[] { new Test9.Document { ID = d1ID, Name = "d1x" } }, new[] { new Test9.Document { ID = d3ID } });
Assert.AreEqual("d1x:1, d2:2, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after update&delete");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:33,代码来源:PersistedDataStructureTest.cs
示例5: ComputeForNewBaseItems_InvalidCommand
public void ComputeForNewBaseItems_InvalidCommand()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var d1ID = Guid.NewGuid();
var d2ID = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM Test9.Document;",
"DELETE FROM Test9.DocumentCreationInfo;",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d2ID + "', 'd2'",
"INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d1ID + "', 1",
"INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d2ID + "', 2",
});
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "initial");
var documents = repository.Test9.Document;
TestUtility.ShouldFail(() => documents.Insert(new[] { new Test9.Document { ID = d1ID, Name = "d1" } }), "existing");
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");
// TODO: Instead of using the wrapper 'Save' function to check data validations, we should handle insert/update/delete events (NHibernate event listener) for faster and more reliable validations.
TestUtility.ShouldFail(() => documents.Update(new[] { new Test9.Document { ID = Guid.NewGuid(), Name = "d3" } }));
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:30,代码来源:PersistedDataStructureTest.cs
示例6: ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate
public void ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var id1 = Guid.NewGuid();
var id2 = Guid.NewGuid();
var id3 = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[] {
"DELETE FROM TestDeactivatable.BasicEnt",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id1) + ", 'a')",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name, Active) VALUES (" + SqlUtility.QuoteGuid(id2) + ", 'b', 0)",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id3) + ", 'c')"
});
var repository = new Common.DomRepository(executionContext);
var e1 = new BasicEnt { ID = id1, Name = "a2", Active = false };
var e2 = new BasicEnt { ID = id2, Name = "b2" };
var e3 = new BasicEnt { ID = id3, Name = "c2" };
repository.TestDeactivatable.BasicEnt.Update(new[] { e1, e2, e3});
var afterUpdate = repository.TestDeactivatable.BasicEnt.All();
Assert.AreEqual(
"a2 False, b2 False, c2 True",
TestUtility.DumpSorted(afterUpdate, item => item.Name + " " + item.Active));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:25,代码来源:DeactivatableTest.cs
示例7: UpdateLockedData
public void UpdateLockedData()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
var s1 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s1", Count = -1 };
var s2 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s2", Count = 1 };
repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
AssertData("s1, s2", repository);
foreach (var e in new[] { s1, s2 })
e.Name = e.Name + "x";
AssertData("s1, s2", repository);
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1 }), "Name is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s2, s1 }), "Name is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1, s2 }), "Name is locked if count negative.");
AssertData("s1, s2", repository);
repository.TestLockItems.Simple.Update(new[] { s2 });
AssertData("s1, s2x", repository);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:26,代码来源:LockPropertyTest.cs
示例8: CRUD
public void CRUD()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var unitTestClaims = repository.Common.Claim.Query().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
Console.WriteLine("Delete old: " + TestUtility.DumpSorted(unitTestClaims, c => c.ClaimResource + "." + c.ClaimRight) + ".");
repository.Common.Claim.Delete(unitTestClaims);
IClaimRepository cr = repository.Common.Claim;
var c1 = new Claim("unittest_c1", "c11");
var c2 = new Claim("unittest_c2", "c22");
var c3 = new Claim("unittest_c3", "c33");
cr.SaveClaims(new[] { c1, c2, c3 }, new ICommonClaim[] {}, new ICommonClaim[] {});
var loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
Assert.AreEqual("c11, c22, c33", TestUtility.Dump(loaded, c => c.ClaimRight));
loaded[0].ClaimRight = loaded[0].ClaimRight.ToUpper();
var c4 = new Claim("unittest_c4", "c44");
cr.SaveClaims(new[] { c4 }, new[] { loaded[0] }, new[] { loaded[1] });
loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
Assert.AreEqual("C11, c33, c44", TestUtility.Dump(loaded, c => c.ClaimRight));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:28,代码来源:ClaimRepositoryTest.cs
示例9: UpdateLockedDataReference
public void UpdateLockedDataReference()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
Guid[] guids = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
var s1 = new TestLockItems.Simple { ID = guids[0], Name = "s1", Count = -1 };
var s2 = new TestLockItems.Simple { ID = guids[1], Name = "s2", Count = 1 };
var t1 = new TestLockItems.Simple2 { ID = guids[2], Name = "t1", TestReference = s1, Count = -1 };
var t2 = new TestLockItems.Simple2 { ID = guids[3], Name = "t2", TestReference = s1, Count = 1 };
repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
AssertData("s1, s2", repository);
repository.TestLockItems.Simple2.Insert(new[] { t1, t2 });
AssertDataSimple2("t1, t2", repository);
foreach (var e in new[] { t1, t2 })
e.TestReference = s1;
repository.TestLockItems.Simple2.Update(new[] { t1 });
AssertDataSimple2("t1, t2", repository);
foreach (var e in new[] { t1, t2 })
e.TestReference = s2;
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1 }), "TestReference is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t2, t1 }), "TestReference is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1, t2 }), "TestReference is locked if count negative.");
AssertDataSimple2("t1, t2", repository);
repository.TestLockItems.Simple2.Update(new[] { t2 });
AssertDataSimple2("t1, t2", repository);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:35,代码来源:LockPropertyTest.cs
示例10: DomRepositoryHasModuleRepositories
public void DomRepositoryHasModuleRepositories()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
Assert.IsNotNull(repository.TestDataStructure);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:8,代码来源:ModuleRepositioryTest.cs
示例11: ShouldThowUserExceptionOnInsert
public void ShouldThowUserExceptionOnInsert()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleRange { FromValue = 1, ToValue = 0 };
repository.TestRange.SimpleRange.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:RangeTest.cs
示例12: NormallyInsertInteger
public void NormallyInsertInteger()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleInteger { Value = 1 };
repository.TestMaxValue.SimpleInteger.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例13: ShouldThowUserExceptionOnInsert
public void ShouldThowUserExceptionOnInsert()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleMaxLength { StringLessThan10Chars = "More than 10 characters." };
repository.TestLengthLimit.SimpleMaxLength.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxLengthTest.cs
示例14: EmptyValuesAreAllowed
public void EmptyValuesAreAllowed()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new Simple { StringFrom200To249 = null };
repository.TestRegex.Simple.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:RegExMatchTest.cs
示例15: NormallyInsertDateTime
public void NormallyInsertDateTime()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleDateTime { Value = new DateTime(2013, 7, 5, 12, 33, 1) };
repository.TestMaxValue.SimpleDateTime.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例16: NormallyInsertDecimal
public void NormallyInsertDecimal()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleDecimal { Value = (decimal)2.30 };
repository.TestMaxValue.SimpleDecimal.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例17: ShouldThowUserExceptionOnUpdate
public void ShouldThowUserExceptionOnUpdate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleMinLength { StringMoreThan2Chars = "." };
repository.TestLengthLimit.SimpleMinLength.Update(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MinLengthTest.cs
示例18: NullString
public void NullString()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestRequired.Simple" });
var repository = new Common.DomRepository(executionContext);
TestUtility.ShouldFail(() => repository.TestRequired.Simple.Insert(new[] { new TestRequired.Simple { Count = 4, Name = null } }), "required", "Name");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:10,代码来源:RequiredPropertyTest.cs
示例19: QueryableFromRepository
public void QueryableFromRepository()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var secondString = repository.TestDataStructure.SqlQueryable1.Query().Where(item => item.i == 2).Select(item => item.s).Single();
Assert.AreEqual("b", secondString);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:10,代码来源:SqlQueryableTest.cs
示例20: ShouldInsertNormallyJustOneDate
public void ShouldInsertNormallyJustOneDate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new DateRangeWithoutDef { FromDate = DateTime.Today };
var entity2 = new DateRangeWithoutDef { ToDate = DateTime.Today };
repository.TestRange.DateRangeWithoutDef.Insert(new[] { entity, entity2 });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:10,代码来源:RangeTest.cs
注:本文中的Common.DomRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论