本文整理汇总了C#中DataLoadOptions类的典型用法代码示例。如果您正苦于以下问题:C# DataLoadOptions类的具体用法?C# DataLoadOptions怎么用?C# DataLoadOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataLoadOptions类属于命名空间,在下文中一共展示了DataLoadOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreated
partial void OnCreated()
{
DataLoadOptions opts = new DataLoadOptions();
opts.LoadWith<Room>(r => r.Computers);
LoadOptions = opts;
}
示例2: btnSubmit_Click
/// <summary>
/// Update profile
/// </summary>
protected void btnSubmit_Click(object sender, EventArgs e)
{
using (var context = new PetShopDataContext())
{
var options = new DataLoadOptions();
options.LoadWith<Profile>(p => p.AccountList);
context.LoadOptions = options;
var profile = context.Profile.GetProfile(User.Identity.Name);
if (!string.IsNullOrEmpty(profile.Username) && AddressForm.IsValid)
{
if (profile.AccountList.Count > 0)
{
Account account = profile.AccountList[0];
UpdateAccount(ref account, AddressForm.Address);
}
else
{
var account = new Account();
profile.AccountList.Add(account);
account.UniqueID = profile.UniqueID;
UpdateAccount(ref account, AddressForm.Address);
}
context.SubmitChanges();
}
}
lblMessage.Text = "Your profile information has been successfully updated.<br> ";
}
示例3: ExecuteQueryLoadWith
public void ExecuteQueryLoadWith()
{
var db = new TrackerDataContext { Log = Console.Out };
db.DeferredLoadingEnabled = false;
db.ObjectTrackingEnabled = false;
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Task>(t => t.CreatedUser);
db.LoadOptions = options;
var q1 = db.User
.ByEmailAddress("[email protected]");
var q2 = db.Task
.Where(t => t.LastModifiedBy == "[email protected]");
var result = db.ExecuteQuery(q1, q2);
Assert.IsNotNull(result);
var userResult = result.GetResult<User>();
Assert.IsNotNull(userResult);
var users = userResult.ToList();
Assert.IsNotNull(users);
var taskResult = result.GetResult<Task>();
Assert.IsNotNull(taskResult);
var tasks = taskResult.ToList();
Assert.IsNotNull(tasks);
}
示例4: PostRepoInit
public override void PostRepoInit()
{
var options = new DataLoadOptions();
options.LoadWith<Sat>(s => s.User);
options.LoadWith<User>(u => u.Tags);
_repo.LoadOptions = options;
}
示例5: GetAthleteClubByTournament
public Inti_AthleteClub GetAthleteClubByTournament(Guid athleteId, Guid tournamentId)
{
using (var db = new IntiDataContext(_connectionString))
{
var dlo = new DataLoadOptions();
dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Club);
dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Position);
dlo.LoadWith<Inti_AthleteClub>(ac => ac.Inti_Athlete);
db.LoadOptions = dlo;
var athleteClubs = from ac in db.Inti_AthleteClub
where ac.AthleteGUID == athleteId &&
ac.Inti_Club.TournamentGUID == tournamentId
select ac;
if(athleteClubs.ToList().Count == 1)
{
var athleteClub = athleteClubs.ToList()[0];
return athleteClub;
}
if (athleteClubs.ToList().Count > 1)
{
throw new ArgumentException("More than one club for the athlete with id {0} in the same tournament.", athleteId.ToString());
}
}
return null;
}
示例6: GetAlgorithms
public IEnumerable<DataTransfer.Algorithm> GetAlgorithms(string platformName) {
roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
using (OKBDataContext okb = new OKBDataContext()) {
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Algorithm>(x => x.AlgorithmClass);
dlo.LoadWith<Algorithm>(x => x.DataType);
dlo.LoadWith<Algorithm>(x => x.AlgorithmUsers);
okb.LoadOptions = dlo;
var query = okb.Algorithms.Where(x => x.Platform.Name == platformName);
List<Algorithm> results = new List<Algorithm>();
if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) {
results.AddRange(query);
} else {
foreach (var alg in query) {
if (alg.AlgorithmUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, alg.AlgorithmUsers.Select(y => y.UserGroupId).ToList())) {
results.Add(alg);
}
}
}
return results.Select(x => Convert.ToDto(x)).ToArray();
}
}
示例7: Command_Should_Parse_Correctly
//[TestMethod()]
public void Command_Should_Parse_Correctly()
{
// ARRANGE
Character toon = null;
InventoryItem invItem = new InventoryItem();
// Get the client's character info
string charName = "Badass";
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Character>(c => c.Account);
dlo.LoadWith<Character>(c => c.Zone);
dlo.LoadWith<Character>(c => c.InventoryItems);
dlo.LoadWith<InventoryItem>(ii => ii.Item);
using (EmuDataContext dbCtx = new EmuDataContext()) {
dbCtx.ObjectTrackingEnabled = false;
dbCtx.LoadOptions = dlo;
toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName);
}
ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123)));
// ACT
//zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage /amount:200 /type:3", 8, 0, 100);
zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage", 8, 0, 100);
// ASSERT
}
示例8: GetServerData
private IEnumerable GetServerData(GridCommand command)
{
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Order>(o => o.Customer);
var dataContext = new NorthwindDataContext
{
LoadOptions = loadOptions
};
IQueryable<Order> data = dataContext.Orders;
//Apply filtering
data = data.ApplyFiltering(command.FilterDescriptors);
ViewData["Total"] = data.Count();
//Apply sorting
data = data.ApplySorting(command.GroupDescriptors, command.SortDescriptors);
//Apply paging
data = data.ApplyPaging(command.Page, command.PageSize);
//Apply grouping
if (command.GroupDescriptors.Any())
{
return data.ApplyGrouping(command.GroupDescriptors);
}
return data.ToList();
}
示例9: Main
static void Main(string[] args)
{
NorthwindDataContext context = new NorthwindDataContext();
//var result = from item in context.Categories
// where item.CategoryID == 48090
// select item;
var result = context.SelectCategory(48090);
foreach (var item in result)
{
Console.WriteLine("{0} {1}", item.CategoryID, item.CategoryName);
}
//context.DeferredLoadingEnabled = false;
var ldOptions = new DataLoadOptions();
ldOptions.AssociateWith<Category>((c) => (c.Products));
context.LoadOptions = ldOptions;
context.ObjectTrackingEnabled = false; // turns DeferredLoadingEnabled to false
var result1 = context.Categories.Where((prod) => (prod.CategoryID == 65985)).Single();
foreach (var item in result1.Products)
{
Console.WriteLine("{0} {1}",item.ProductID, item.ProductName);
}
Console.WriteLine();
Compile();
//Query2();
//DirectExe();
//Modify();
//Trans();
//MyDel();
//Track();
CreateDB();
Console.ReadLine();
}
示例10: Get
public IPhishDatabase Get()
{
if (_database == null)
{
DataLoadOptions options = new DataLoadOptions();
//options.LoadWith<Tour>(tour => tour.Shows);
//options.LoadWith<Show>(show => show.Sets);
//options.LoadWith<Set>(set => set.SetSongs);
//options.LoadWith<Set>(set => set.Show);
//options.LoadWith<SetSong>(setSong => setSong.Song);
//options.LoadWith<SetSong>(setSong => setSong.Set);
//options.LoadWith<Song>(song => song.set
_database = new PhishDatabase(_connectionString)
{
LoadOptions = options,
DeferredLoadingEnabled = true,
Log = (_logWriter == null ? null : _logWriter.Get())
};
}
return _database;
}
示例11: Details
public ActionResult Details(int id)
{
IPFinalDBDataContext finalDB = new IPFinalDBDataContext();
DataLoadOptions ds = new DataLoadOptions();
ds.LoadWith<Work_Package>(wp => wp.Package_Softwares);
ds.LoadWith<Package_Software>(ps => ps.Software_Requirement);
finalDB.LoadOptions = ds;
var pack = (from p in finalDB.Work_Packages
where p.id == id
select p).Single();
//var data = from sr in finalDB.Software_Requirements
// join ps in finalDB.Package_Softwares
// on sr.id equals ps.sr_id
// where ps.wp_id == id
// select sr;
//foreach (var ps in data)
//{
// pack.Package_Softwares.Add(new Package_Software()
// {
// Software_Requirement = ps,
// Work_Package = pack
// });
//}
return View(pack);
}
示例12: UserManager
/// <summary>
/// User Manager
/// </summary>
public UserManager()
{
db = new BizzyQuoteDataContext(Properties.Settings.Default.BizzyQuoteConnectionString);
var options = new DataLoadOptions();
options.LoadWith<User>(u => u.Company);
db.LoadOptions = options;
}
示例13: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int personId = 0;
if (Request.QueryString["id"] != null && int.TryParse(TamperProofString.QueryStringDecode(Request.QueryString["id"]), out personId))
{
Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Ajancy.Person>(p => p.DrivingLicenses);
dlo.LoadWith<Ajancy.Person>(p => p.DriverCertifications);
dlo.LoadWith<Ajancy.DriverCertification>(dc => dc.DriverCertificationCars);
dlo.LoadWith<Ajancy.DriverCertificationCar>(dcc => dcc.CarPlateNumber);
dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.PlateNumber);
dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.Car);
dlo.LoadWith<Ajancy.Car>(c => c.FuelCards);
dlo.LoadWith<Ajancy.Car>(c => c.CarType);
db.LoadOptions = dlo;
SetPerson(db.Persons.FirstOrDefault<Ajancy.Person>(p => p.PersonID == personId));
db.Dispose();
}
else
{
Response.Redirect("~/Default.aspx");
}
}
}
示例14: Save
public void Save(params ContentType[] contentTypes)
{
using (var ts = new TransactionScope())
using (var dataContext = new ContentDataContext(connectionString))
{
var loadOptions = new DataLoadOptions();
loadOptions.LoadWith<ContentTypeItem>(ct => ct.ContentActionItems);
dataContext.LoadOptions = loadOptions;
var contentTypeItems = dataContext.ContentTypeItems.ToList();
var itemsToDelete = from data in contentTypeItems
where !contentTypes.Any(t => t.Type == data.Type && t.ControllerName == data.ControllerName)
select data;
var itemsToUpdate = (from data in contentTypeItems
let type = contentTypes.SingleOrDefault(t => t.Type == data.Type && t.ControllerName == data.ControllerName)
where type != null
select new { data, type }).ToList();
var itemsToInsert = (from type in contentTypes
where !contentTypeItems.Any(t => t.Type == type.Type && t.ControllerName == type.ControllerName)
select CreateContentTypeItem(type)).ToList();
itemsToUpdate.ForEach(i => UpdateContentTypeItem(i.data, i.type, dataContext));
dataContext.ContentTypeItems.DeleteAllOnSubmit(itemsToDelete);
dataContext.ContentTypeItems.InsertAllOnSubmit(itemsToInsert);
dataContext.SubmitChanges();
ts.Complete();
}
}
示例15: GetDefaultDataLoadOptions
private static DataLoadOptions GetDefaultDataLoadOptions()
{
var lo = new DataLoadOptions();
lo.LoadWith<Document>(c => c.Employee);
lo.LoadWith<Document>(c => c.Employee1);
lo.LoadWith<DocumentTransitionHistory>(c=>c.Employee);
return lo;
}