本文整理汇总了C#中DbSet类的典型用法代码示例。如果您正苦于以下问题:C# DbSet类的具体用法?C# DbSet怎么用?C# DbSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DbSet类属于命名空间,在下文中一共展示了DbSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
示例2: RemoveDbSetDataDatabase
public void RemoveDbSetDataDatabase(DbSet set)
{
RemoveDbSetData(set);
SaveChanges();
dataDeleter.DeleteAllObjects();
}
示例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;
}
示例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);
}
示例5: LgEloquaContext
public LgEloquaContext(IRestClient restClient)
: base(restClient)
{
BadContacts = new DbSet<BadContact>(restClient);
LgContacts = new DbSet<LgContact>(restClient);
ExtendedContacts = new DbSet<ExtendedContact>(restClient);
}
示例6: ComputerRepository
public ComputerRepository(DbSet<ComputerModel> computers, Action save, DbSet<ScriptModel> scripts, DbSet<UserModel> users)
{
_computers = computers;
_save = save;
_scripts = scripts;
_users = users;
}
示例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;
}
示例8: NetworkGuestRepository
public NetworkGuestRepository(DbSet<NetworkGuestModel> entries, DbSet<NetworkModel> networks, Action save, DbSet<UserModel> users)
{
_entries = entries;
_networks = networks;
_save = save;
_users = users;
}
示例9: ConnectedRepository
public ConnectedRepository()
{
_context = new NinjaContext();
_ninjas = _context.Ninjas;
_clans = _context.Clans;
_equipment = _context.Equipment;
}
示例10: StudentRepository
public StudentRepository(StuaContext context)
{
this.context = context;
studenten = context.Studenten;
stages = context.Stages;
favorietestages = context.StudentStage;
}
示例11: BedrijfRepository
// Constructor
public BedrijfRepository(InternshipContext context)
{
this.context = context;
bedrijven = context.Bedrijven;
opdrachten = context.Opdrachten;
contactpersonen = context.ContactPersonen;
}
示例12: UnitRepository
public UnitRepository(IUnitOfWork unitOfWork, IDocRepository docRepository, IDomainValidator validator)
{
this.unitOfWork = unitOfWork;
this.docRepository = docRepository;
this.validator = validator;
unitsInContext = unitOfWork.DbContext.Set<Unit>();
}
示例13: BegeleiderRepository
public BegeleiderRepository(StuaContext context)
{
this.context = context;
begeleiders = context.Begeleiders;
stages = context.Stages;
studenten = context.Studenten;
}
示例14: BedrijfRepository
public BedrijfRepository(StuaContext context)
{
this.context = context;
bedrijven = context.Bedrijven;
stages = context.Stages;
bedrijfspersonen = context.Bedrijfspersonen;
}
示例15: DataProvider
public DataProvider(Dictionary<string, string> cons) {
//Create movie context
dbConnString = cons["SqlConnString"];
db = new MoviesContext(dbConnString);
Movies = db.Movies;
}