本文整理汇总了C#中DbSet类的典型用法代码示例。如果您正苦于以下问题:C# DbSet类的具体用法?C# DbSet怎么用?C# DbSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbSet类属于命名空间,在下文中一共展示了DbSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Transfer
public static void Transfer(SupermarketsEntities sqlserver)
{
using (var mysql = new MySqlSupermarket())
{
// SET IDENTITY_INSERT (Transact-SQL) http://msdn.microsoft.com/en-us/library/ms188059.aspx
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Vendors ON");
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Measures ON");
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Products ON");
var mysqlTables = new IEnumerable[] { mysql.Vendors, mysql.Measures, mysql.Products };
var sqlserverEntityFactories = new Func<object>[] { () => new Vendor(), () => new Measure(), () => new Product() };
var sqlserverTables = new DbSet[] { sqlserver.Vendors, sqlserver.Measures, sqlserver.Products };
for (int ii = 0; ii < mysqlTables.Length; ii++)
{
foreach (var mysqlObject in mysqlTables[ii])
{
var sqlserverObject = sqlserverEntityFactories[ii]();
sqlserverObject.LoadPropertiesFrom(mysqlObject);
sqlserverTables[ii].Add(sqlserverObject);
}
}
sqlserver.SaveChanges();
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Vendors OFF");
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Measures OFF");
sqlserver.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Products OFF");
}
}
开发者ID:VelizarIT,项目名称:db-project-2013,代码行数:30,代码来源:MySqlTransfer.cs
示例2: RemoveDbSetDataDatabase
public void RemoveDbSetDataDatabase(DbSet set)
{
RemoveDbSetData(set);
SaveChanges();
dataDeleter.DeleteAllObjects();
}
开发者ID:Tjitse,项目名称:sogeti.capstone,代码行数:7,代码来源:CapstoneContext.cs
示例3: NewestSubmissionsFromASub
public static IQueryable<SetSubmission> NewestSubmissionsFromASub(string subverseName, DbSet<Message> messagesDbSet, string setName, int desiredResults)
{
var topRankedSubmissions = (from message in messagesDbSet
where !message.IsDeleted && message.Subverse == subverseName
select new SetSubmission
{
Id = message.Id,
Votes = message.Votes,
Name = message.Name,
Date = message.Date,
Type = message.Type,
Linkdescription = message.Linkdescription,
Title = message.Title,
Rank = message.Rank,
MessageContent = message.MessageContent,
Subverse = message.Subverse,
Likes = message.Likes,
Dislikes = message.Dislikes,
Thumbnail = message.Thumbnail,
LastEditDate = message.LastEditDate,
FlairLabel = message.FlairLabel,
FlairCss = message.FlairCss,
Anonymized = message.Anonymized,
Views = message.Views,
Comments = message.Comments,
Votingtrackers = message.Votingtrackers,
Subverses = message.Subverses,
Stickiedsubmission = message.Stickiedsubmission,
Viewstatistics = message.Viewstatistics,
ParentSet = setName
}).OrderByDescending(s => s.Date).Take(desiredResults).AsNoTracking();
return topRankedSubmissions;
}
开发者ID:Rumel,项目名称:voat,代码行数:34,代码来源:SetsUtility.cs
示例4: DbSetGetAsyncTest
public async Task DbSetGetAsyncTest()
{
//Arrange
var mockRestResponse = new Mock<IRestResponse>();
mockRestResponse.SetupGet(o => o.ResponseStatus).Returns(ResponseStatus.Completed);
mockRestResponse.SetupGet(o => o.StatusCode).Returns(HttpStatusCode.OK);
mockRestResponse.SetupGet(o => o.Content).Returns(@"{
""contactId"": ""48620"",
""id"": ""10002"",
""fieldValues"": [
{
""id"": ""824"",
""value"": ""transxId12321321321321""
}
],
""name"": ""Test Name WHAT IS THIS"",
""uri"": ""/data/customObject""
}
");
var mockRestClient = new Mock<IRestClient>();
mockRestClient.Setup(o => o.ExecuteTaskAsync(It.IsAny<IRestRequest>())).ReturnsAsync(mockRestResponse.Object);
var dbSet = new DbSet<MockDbsetWithDataContact>(mockRestClient.Object);
//Act
var contact = await dbSet.GetAsync(1, Depth.Complete);
//Assert
Assert.AreEqual(10002, contact.Id);
}
开发者ID:SourceDecoded,项目名称:eloqua-csharp-rest-client,代码行数:32,代码来源:DbSetTests.cs
示例5: LgEloquaContext
public LgEloquaContext(IRestClient restClient)
: base(restClient)
{
BadContacts = new DbSet<BadContact>(restClient);
LgContacts = new DbSet<LgContact>(restClient);
ExtendedContacts = new DbSet<ExtendedContact>(restClient);
}
开发者ID:SourceDecoded,项目名称:eloqua-csharp-rest-client,代码行数:7,代码来源:LgEloquaContext.cs
示例6: ComputerRepository
public ComputerRepository(DbSet<ComputerModel> computers, Action save, DbSet<ScriptModel> scripts, DbSet<UserModel> users)
{
_computers = computers;
_save = save;
_scripts = scripts;
_users = users;
}
开发者ID:Mavtak,项目名称:roomie,代码行数:7,代码来源:ComputerRepository.cs
示例7: NewestSubmissionsFromASub
public static IQueryable<SetSubmission> NewestSubmissionsFromASub(string subverseName, DbSet<Submission> submissionDBSet, string setName, int desiredResults)
{
var topRankedSubmissions = (from submission in submissionDBSet
where !submission.IsDeleted && submission.Subverse == subverseName
select new SetSubmission
{
ID = submission.ID,
Votes = submission.Votes,
UserName = submission.UserName,
CreationDate = submission.CreationDate,
Type = submission.Type,
LinkDescription = submission.LinkDescription,
Title = submission.Title,
Rank = submission.Rank,
Content = submission.Content,
Subverse = submission.Subverse,
UpCount = submission.UpCount,
DownCount = submission.DownCount,
Thumbnail = submission.Thumbnail,
LastEditDate = submission.LastEditDate,
FlairLabel = submission.FlairLabel,
FlairCss = submission.FlairCss,
IsAnonymized = submission.IsAnonymized,
Views = submission.Views,
Comments = submission.Comments,
SubmissionVoteTrackers = submission.SubmissionVoteTrackers,
Subverse1 = submission.Subverse1,
StickiedSubmission = submission.StickiedSubmission,
ViewStatistics = submission.ViewStatistics,
ParentSet = setName
}).OrderByDescending(s => s.CreationDate).Take(desiredResults).AsNoTracking();
return topRankedSubmissions;
}
开发者ID:CuteThalia,项目名称:voat,代码行数:34,代码来源:SetsUtility.cs
示例8: NetworkGuestRepository
public NetworkGuestRepository(DbSet<NetworkGuestModel> entries, DbSet<NetworkModel> networks, Action save, DbSet<UserModel> users)
{
_entries = entries;
_networks = networks;
_save = save;
_users = users;
}
开发者ID:Mavtak,项目名称:roomie,代码行数:7,代码来源:NetworkGuestRepository.cs
示例9: FakeLagaModelDbContext
public FakeLagaModelDbContext()
{
LoggerEntries = new FakeDbSet<LoggerEntry>();
LoggerOperations = new FakeDbSet<LoggerOperation>();
LoggerThreads = new FakeDbSet<LoggerThread>();
LoggerThreadStatus = new FakeDbSet<LoggerThreadStatus>();
}
开发者ID:drydenmaker,项目名称:EF.Reverse.Poco.Generator.Migrations,代码行数:7,代码来源:FakeLagaModelDbContext.cs
示例10: ClearDatabase
private void ClearDatabase(DbSet<CoffeeShop> coffeeShops)
{
foreach (var shop in coffeeShops)
{
coffeeShops.Remove(shop);
}
}
开发者ID:swegner,项目名称:coffee-map,代码行数:7,代码来源:CoffeeScraper.cs
示例11: RemoveDbSetData
private void RemoveDbSetData(DbSet set)
{
foreach (var @entity in set)
{
set.Remove(@entity);
}
}
开发者ID:Tjitse,项目名称:sogeti.capstone,代码行数:7,代码来源:CapstoneContext.cs
示例12: NetworkRepository
public NetworkRepository(DbSet<NetworkModel> networks, DbSet<ComputerModel> computers, Action save, DbSet<UserModel> users)
{
_networks = networks;
_computers = computers;
_save = save;
_users = users;
}
开发者ID:Mavtak,项目名称:roomie,代码行数:7,代码来源:NetworkRepository.cs
示例13: ConnectedRepository
public ConnectedRepository()
{
_context = new NinjaContext();
_ninjas = _context.Ninjas;
_clans = _context.Clans;
_equipment = _context.Equipment;
}
开发者ID:toddbadams,项目名称:FunWithEf,代码行数:7,代码来源:ConnectedRepository.cs
示例14: StudentRepository
public StudentRepository(StuaContext context)
{
this.context = context;
studenten = context.Studenten;
stages = context.Stages;
favorietestages = context.StudentStage;
}
开发者ID:pspletinckx,项目名称:HG_P2_2014_NET,代码行数:7,代码来源:StudentRepository.cs
示例15: BedrijfRepository
// Constructor
public BedrijfRepository(InternshipContext context)
{
this.context = context;
bedrijven = context.Bedrijven;
opdrachten = context.Opdrachten;
contactpersonen = context.ContactPersonen;
}
开发者ID:steviedc69,项目名称:TheInternshipMVC5,代码行数:8,代码来源:BedrijfRepository.cs
示例16: UnitRepository
public UnitRepository(IUnitOfWork unitOfWork, IDocRepository docRepository, IDomainValidator validator)
{
this.unitOfWork = unitOfWork;
this.docRepository = docRepository;
this.validator = validator;
unitsInContext = unitOfWork.DbContext.Set<Unit>();
}
开发者ID:MartinBG,项目名称:Gva,代码行数:7,代码来源:UnitRepository.cs
示例17: BegeleiderRepository
public BegeleiderRepository(StuaContext context)
{
this.context = context;
begeleiders = context.Begeleiders;
stages = context.Stages;
studenten = context.Studenten;
}
开发者ID:pspletinckx,项目名称:HG_P2_2014_NET,代码行数:7,代码来源:BegeleiderRepository.cs
示例18: BedrijfRepository
public BedrijfRepository(StuaContext context)
{
this.context = context;
bedrijven = context.Bedrijven;
stages = context.Stages;
bedrijfspersonen = context.Bedrijfspersonen;
}
开发者ID:pspletinckx,项目名称:HG_P2_2014_NET,代码行数:7,代码来源:BedrijfRepository.cs
示例19: DataProvider
public DataProvider(Dictionary<string, string> cons) {
//Create movie context
dbConnString = cons["SqlConnString"];
db = new MoviesContext(dbConnString);
Movies = db.Movies;
}
开发者ID:banlong,项目名称:OMDBMovies,代码行数:7,代码来源:DataProvider.cs
示例20: InvoiceItemService
public InvoiceItemService()
{
_repository = new invoicesEntities();
_invoices = _repository.Set<Invoice>();
_invoiceItems = _repository.Set<InvoiceItem>();
_products = _repository.Set<Product>();
}
开发者ID:txsll,项目名称:SLLInvoices,代码行数:7,代码来源:InvoiceItemService.cs
注:本文中的DbSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论