本文整理汇总了C#中GenericRepository.Get方法的典型用法代码示例。如果您正苦于以下问题:C# GenericRepository.Get方法的具体用法?C# GenericRepository.Get怎么用?C# GenericRepository.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericRepository
的用法示例。
在下文中一共展示了GenericRepository.Get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ViewResult Index()
{
IList<Models.Nanny> nannies = null;
var db = NannyContext.Create();
GenericRepository<Models.Nanny> repository = new GenericRepository<Models.Nanny>(db);
nannies = repository.Get().ToList();
return View(nannies);
}
示例2: GetRefTerrain
public REF_Terrain[] GetRefTerrain()
{
using (var dataContext = new AusterlitzDbContext())
{
var listRepository = new GenericRepository<REF_Terrain>(dataContext);
IEnumerable<REF_Terrain> rtnList = listRepository
.Get();
return rtnList.ToArray();
}
}
示例3: GetRefStates
public REF_States[] GetRefStates()
{
using (var dataContext = new AusterlitzDbContext())
{
var listRepository = new GenericRepository<REF_States>(dataContext);
IEnumerable<REF_States> rtnList = listRepository
.Get()
.OrderBy(y => y.State);
return rtnList.ToArray();
}
}
示例4: GetMapCoordinates
public DisplayCoordinate[][] GetMapCoordinates(string turnId)
{
var displayMapArray = new DisplayCoordinate[100][];
using (var dataContext = new AusterlitzDbContext())
{
var turnMap = new GenericRepository<TR_MapCoordinates>(dataContext);
var regionalMap = new GenericRepository<REF_PoliticalMapCoordinates>(dataContext);
var turnCoordinateList = turnMap.GetItems(x => x.TurnId == turnId);
var regionalCoordinateList = regionalMap.Get();
var rulesCatalogApiController = new RulesCatalogApiController();
var refProductionSites = rulesCatalogApiController.GetRefProductionSites();
for (var y = 0; y <= 99; y++)
{
displayMapArray[y] = new DisplayCoordinate[91];
for (var x = 0; x <= 90; x++)
{
var turnCoord = turnCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);
var regionalCoord = regionalCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);
if (turnCoord != null && regionalCoord != null)
{
displayMapArray[turnCoord.Y][turnCoord.X] = new DisplayCoordinate()
{
X = x,
Y = y,
TurnId = turnId,
Population = turnCoord.Population,
ProductionSite = turnCoord.ProductionSite.Replace(".",""),
State = turnCoord.State,
Bonus = regionalCoord.Bonus,
Owner = regionalCoord.Owner,
Terrain = regionalCoord.Terrain,
};
//displayMapArray[turnCoord.Y][turnCoord.X].allowableProdSites = calcAllowableProdSites(displayMapArray[turnCoord.Y][turnCoord.X], refProductionSites, state);
}
else
{
displayMapArray[y][x] = new DisplayCoordinate()
{
X = x,
Y = y,
TurnId = turnId,
Population = ".",
ProductionSite = " ",
State = " ",
Bonus = " ",
Owner = " ",
Terrain = " "
};
}
if (x == 0)
displayMapArray[y][x].Population = x.ToString();
else if (y == 0)
displayMapArray[y][x].Population = y.ToString();
}
}
return displayMapArray;
}
}
示例5: Get_With_NULL_Filter_Must_Return__All
public void Get_With_NULL_Filter_Must_Return__All()
{
//
// Arrange
//
var models = Enumerable.Range(1, 10).Select(x =>
{
var mockModel = new Mock<IModel>();
mockModel.Setup(y => y.Id).Returns(x);
return mockModel.Object;
}).AsQueryable();
var mockDbSet = new Mock<DbSet<IModel>>();
mockDbSet.As<IQueryable<IModel>>().Setup(m => m.Provider).Returns(models.Provider);
mockDbSet.As<IQueryable<IModel>>().Setup(m => m.Expression).Returns(models.Expression);
mockDbSet.As<IQueryable<IModel>>().Setup(m => m.ElementType).Returns(models.ElementType);
mockDbSet.As<IQueryable<IModel>>().Setup(m => m.GetEnumerator()).Returns(models.GetEnumerator());
var mockContext = new Mock<EFDbContext>();
mockContext.Setup(x => x.Set<IModel>()).Returns(mockDbSet.Object);
var repository = new GenericRepository<IModel>(mockContext.Object);
Expression<Func<IModel, bool>> filterExpression = null;
//
// Act
//
var results = repository.Get(filterExpression);
//
// Assert
//
Assert.IsNotNull(results);
Assert.IsNotNull(results.First());
Assert.AreEqual(10, results.Count());
Assert.AreEqual(1, results.First().Id);
}
示例6: GetProvinces
public List<Location> GetProvinces()
{
GenericRepository<Location> locationRepo = new GenericRepository<Location>();
return locationRepo.Get(l => l.ParentId == -1).ToList();
}
示例7: GetDistrictsByProvince
public List<Location> GetDistrictsByProvince(int provinceId)
{
GenericRepository<Location> locationRepo = new GenericRepository<Location>();
return locationRepo.Get(l => l.ParentId == provinceId).ToList();
}
示例8: AddLanguageSkill
public async Task<ActionResult> AddLanguageSkill([Bind(Include = "IdNanny, IdLanguage, IdLanguageLevel")] LanguageSkill model)
{
try
{
if (!ModelState.IsValid)
{
return PartialView("Profile");
}
model.DateCreated = DateTime.UtcNow;
model.DateLastUpdated = DateTime.UtcNow;
GenericRepository<LanguageSkill> repositoryqLanguageSkill = new GenericRepository<LanguageSkill>(new NannyContext());
repositoryqLanguageSkill.Insert(model);
repositoryqLanguageSkill.Save();
IEnumerable<LanguageSkill> languages = repositoryqLanguageSkill.Get().Where(l => l.IdNanny == model.IdNanny).ToList();
ViewBag.LanguageSkills = languages;
return GetMenu("LanguageSkill");
}
catch (DataException dex)
{
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
}
return View(model);
}
示例9: LanguageSkill_List
//[ActionName("LanguageSkill_Edit")]
//public PartialViewResult LanguageSkill_Edit(Int64 idNanny)
//{
// LanguageSkill model = new Models.LanguageSkill();
// model.IdNanny = idNanny;
// ViewBag.Languages = new GenericRepository<Language>(new NannyDBContext()).Get();
// ViewBag.LanguageLevels = new GenericRepository<LanguageLevel>(new NannyDBContext()).Get();
// return PartialView(model);
//}
public ActionResult LanguageSkill_List()
{
GenericRepository<LanguageSkill> repositoryqLanguageSkill = new GenericRepository<LanguageSkill>(new NannyContext());
IEnumerable<LanguageSkill> languages = repositoryqLanguageSkill.Get().Where(l => l.IdNanny == Guid.NewGuid()).ToList();
ViewBag.LanguageSkills = languages;
return PartialView("LanguageSkill_List", languages);
}