本文整理汇总了C#中Repository.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Remove方法的具体用法?C# Repository.Remove怎么用?C# Repository.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory
public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory(
bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus)
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);
Assert.Equal(initialStatus, repo.RetrieveStatus(filename));
Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
if (throws)
{
Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename, removeFromWorkdir));
Assert.Equal(count, repo.Index.Count);
}
else
{
repo.Remove(filename, removeFromWorkdir);
Assert.Equal(count - 1, repo.Index.Count);
Assert.Equal(existsAfterRemove, File.Exists(fullpath));
Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
}
}
}
示例2: Delete
public void Delete()
{
using (var context = new MainContext())
{
var myRepo = new Repository<Core.Customer>(context);
TotalCustomersBeforeTestRuns = myRepo.GetAll().Count();
var allEntities = myRepo.GetAll().ToList();
if (allEntities.Count > 0)
{
//Find an entity to be removed.
var firstClientInTheDb = allEntities.FirstOrDefault();
//Check if there is an entity to be removed
if (firstClientInTheDb != null)
{
myRepo.Remove(firstClientInTheDb.Id);
myRepo.Save();
TotalOfClientsAfterTheTestRuns = myRepo.GetAll().Count();
// Check if the total number of entites was reduced by one.
Assert.AreEqual(TotalCustomersBeforeTestRuns - 1, TotalOfClientsAfterTheTestRuns);
}
}
}
}
示例3: CanResolveConflictsByRemovingFromTheIndex
public void CanResolveConflictsByRemovingFromTheIndex(
bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries)
{
var path = SandboxMergedTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);
Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
Assert.NotNull(repo.Index.Conflicts[filename]);
Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count());
repo.Remove(filename, removeFromWorkdir);
Assert.Null(repo.Index.Conflicts[filename]);
Assert.Equal(count - removedIndexEntries, repo.Index.Count);
Assert.Equal(existsAfterRemove, File.Exists(fullpath));
Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count());
Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]);
}
}
示例4: Remove
public void Remove()
{
Repository repository = new Repository();
UserModel user = new UserModel();
user.Id = 4;
repository.Remove<UserModel>(user);
}
示例5: CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD
public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD()
{
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
int count = repo.Index.Count;
Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
repo.Remove("1");
Assert.False(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
Assert.Equal(count - 1, repo.Index.Count);
}
}
示例6: DeleteTest
public void DeleteTest()
{
IRepository<Pacient> rep = new Repository<Pacient>(path);
int i = rep.GetAll().Count();
rep.Remove(10);
if (i > 0)
{
i--;
}
else
{
i = 0;
}
Assert.AreEqual(rep.GetAll().Count(), i);
}
示例7: Dispose
public virtual void Dispose()
{
//Clean the database
using (var context = new MainContext())
{
var myRepo = new Repository<Address>(context);
//Get the Address to be removed.
MyNewAddress = myRepo.Query(s => s.AddressLine1 == MyNewAddress.AddressLine1).FirstOrDefault();
if (myRepo.GetAll().Any())
{
myRepo.Remove(MyNewAddress);
myRepo.Save();
}
}
}
示例8: RemoveInstanceTest
public void RemoveInstanceTest()
{
var p = new Person
{
Name = "John Doe",
Age = 24,
Email = "[email protected]",
};
var crate = new Repository("Crate");
crate.Remove(p);
var actual = crate.Data.First(c => c.Name == "Person").Type;
const OperationType expected = OperationType.Removing;
Assert.AreEqual(expected, actual);
}
示例9: CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles
public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles()
{
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone"));
repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/3.txt", "too"));
repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir2/4.txt", "tree"));
repo.Stage(Touch(repo.Info.WorkingDirectory, "2/5.txt", "for"));
repo.Stage(Touch(repo.Info.WorkingDirectory, "2/6.txt", "fyve"));
int count = repo.Index.Count;
Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "2")));
repo.Remove("2", false);
Assert.Equal(count - 5, repo.Index.Count);
}
}
示例10: Main
static void Main(string[] args)
{
IRepository repo = new Repository();
Product product = new Product(5, 55.5m, "kalipso", "djolan");
Product product2 = new Product(6, 55.6m, "kalipso", "djolan");
Product product3 = new Product(7, 55.5m, "kalipso", "djolan");
Product product4 = new Product(8, 55.5m, "kalipso", "djolan");
repo.Add(product);
repo.Add(product2);
repo.Add(product3);
repo.Add(product4);
var productsByTitle = repo.FindByTitle("kalipso");
var productsBySupplierAndPriceRange = repo.FindBySupplierAndPriceRange("djolan", 55.5m, 55.6m);
var productByTitleAndPriceRange = repo.FindByTitleAndPriceRange("kalipso", 55.5m, 55.6m);
var productByPriceRange = repo.FindByPriceRange(55.5m, 55.6m);
var productsByTitleAndPrice = repo.FindByTitleAndPrice("kalipso", 55.5m);
var productsBySupplierAndPrice = repo.FindBySupplierAndPrice("djolan", 55.5m);
bool isSuccessfullyRemoved = repo.Remove(product.Id);
}
示例11: CanDetectABinaryDeletion
public void CanDetectABinaryDeletion()
{
using (var repo = new Repository(SandboxStandardTestRepo()))
{
const string filename = "binfile.foo";
var filepath = Path.Combine(repo.Info.WorkingDirectory, filename);
CreateBinaryFile(filepath);
repo.Stage(filename);
var commit = repo.Commit("Add binary file", Constants.Signature, Constants.Signature);
File.Delete(filepath);
var patch = repo.Diff.Compare<Patch>(commit.Tree, DiffTargets.WorkingDirectory, new [] {filename});
Assert.True(patch[filename].IsBinaryComparison);
repo.Remove(filename);
var commit2 = repo.Commit("Delete binary file", Constants.Signature, Constants.Signature);
var patch2 = repo.Diff.Compare<Patch>(commit.Tree, commit2.Tree, new[] { filename });
Assert.True(patch2[filename].IsBinaryComparison);
}
}
示例12: using
public int 仓库信息_Delete(string 仓库信息编码)
{
using (var context = new BDKRContext())
{
var r = new Repository<仓库信息>(context);
var e = r.GetSingle(t => t.编码 == 仓库信息编码);
if (null == e)
throw new Exception("仓库信息并不存在");
if (e.实时库存明细List != null && e.实时库存明细List.Count > 0)
throw new Exception("实时库存中含有此仓库信息,无法删除!");
if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0)
throw new Exception("采购进货单明细中含有此仓库信息,无法删除!");
return r.Remove(e);
}
}
示例13: InsertAndRemove
//===============================================================
public static void InsertAndRemove(Repository<TestClass> testObjects)
{
var testObj = new TestClass("myKey", "myValue");
testObjects.Insert(testObj);
testObjects.SaveChanges();
var storedObj = testObjects.Find(testObj.ID);
Assert.NotNull(storedObj.Object);
Assert.AreEqual(testObj.ID, storedObj.Object.ID);
Assert.AreEqual(testObj.ID, storedObj.Object.ID);
testObjects.Remove(testObj);
testObjects.SaveChanges();
storedObj = testObjects.Find(testObj.ID);
Assert.Null(storedObj);
testObjects.RemoveAll();
testObjects.SaveChanges();
}
示例14: CanMergeIntoOrphanedBranch
public void CanMergeIntoOrphanedBranch()
{
string path = SandboxMergeTestRepo();
using (var repo = new Repository(path))
{
repo.Refs.Add("HEAD", "refs/heads/orphan", true);
// Remove entries from the working directory
foreach(var entry in repo.RetrieveStatus())
{
repo.Unstage(entry.FilePath);
repo.Remove(entry.FilePath, true);
}
// Assert that we have an empty working directory.
Assert.False(repo.RetrieveStatus().Any());
MergeResult result = repo.Merge("master", Constants.Signature);
Assert.Equal(MergeStatus.FastForward, result.Status);
Assert.Equal(masterBranchInitialId, result.Commit.Id.Sha);
Assert.False(repo.RetrieveStatus().Any());
}
}
示例15: RemoveEntryFromRepositoryTest
public void RemoveEntryFromRepositoryTest()
{
const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
var dc = new SqlServerContext(connectionString, "");
var p = new Person
{
Name = "John Doe",
Age = 24,
Email = "[email protected]"
};
var repository = new Repository("ConsoleApp");
dc.Clear<Person>(repository);
repository.Add(p);
dc.SubmitChanges(repository);
repository.Remove(p);
dc.SubmitChanges(repository);
var people = dc.Select<Person>(repository);
Assert.AreEqual(0, people.Count());
}