本文整理汇总了C#中IZetboxContext.GetQuery方法的典型用法代码示例。如果您正苦于以下问题:C# IZetboxContext.GetQuery方法的具体用法?C# IZetboxContext.GetQuery怎么用?C# IZetboxContext.GetQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IZetboxContext
的用法示例。
在下文中一共展示了IZetboxContext.GetQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEnumList
public static IQueryable<Enumeration> GetEnumList(IZetboxContext ctx)
{
if (ctx == null) { throw new ArgumentNullException("ctx"); }
return from e in ctx.GetQuery<Enumeration>()
select e;
}
示例2: SetUp
public override void SetUp()
{
base.SetUp();
ctx = GetContext();
var objs = ctx.GetQuery<ObjectClass>().Take(10).ToList();
guids = objs.Select(cls => cls.ExportGuid).ToList();
}
示例3: SetUp
public override void SetUp()
{
base.SetUp();
ctx = GetContext();
var principalResolver = scope.Resolve<IPrincipalResolver>();
var currentPrincipal = principalResolver.GetCurrent();
Assert.That(currentPrincipal, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly");
identity1 = ctx.Find<Identity>(currentPrincipal.ID);
identity2 = ctx.GetQuery<Identity>().Where(i => i.ID != identity1.ID).First();
parent = ctx.Create<SecurityTestParent>();
parent.Name = "MyParent";
child1 = ctx.Create<SecurityTestChild>();
child1.Name = "Child1";
child1.Identity = identity1;
child1.Parent = parent;
child2 = ctx.Create<SecurityTestChild>();
child2.Name = "Child2";
child2.Identity = identity2;
child2.Parent = parent;
ctx.SubmitChanges();
}
示例4: GetCompoundObjectList
public static IQueryable<CompoundObject> GetCompoundObjectList(IZetboxContext ctx)
{
if (ctx == null) { throw new ArgumentNullException("ctx"); }
return from s in ctx.GetQuery<CompoundObject>()
select s;
}
示例5: GetInterfaceList
public static IQueryable<Interface> GetInterfaceList(IZetboxContext ctx)
{
if (ctx == null) { throw new ArgumentNullException("ctx"); }
return from i in ctx.GetQuery<Interface>()
select i;
}
示例6: TearDown
public override void TearDown()
{
ctx = GetContext();
var tdObj = ctx.GetQuery<TestObjClass>().Where(a => a.ID == originalId);
foreach (var o in tdObj.ToList())
{
ctx.Delete(o);
}
base.TearDown();
}
示例7: InitTestObjects
public void InitTestObjects()
{
DeleteTestData();
CreateTestData();
ctx = GetContext();
obj = ctx.GetQuery<TestCustomObject>().First();
testNumber = "TestNumber " + rnd.NextDouble().ToString(CultureInfo.InvariantCulture);
}
示例8: ToRef
/// <returns>a Zetbox TypeRef for a given System.Type</returns>
public static TypeRef ToRef(this Type t, IZetboxContext ctx)
{
if (t == null) { throw new ArgumentNullException("t"); }
if (ctx == null) { throw new ArgumentNullException("ctx"); }
// TODO: think about and implement naked types (i.e. without arguments)
if (t.IsGenericTypeDefinition) { throw new ArgumentOutOfRangeException("t"); }
var result = GetFromCache(t, ctx);
if (result != null) return result;
result = LookupByType(ctx, ctx.GetQuery<TypeRef>(), t);
if (result == null)
{
result = CreateTypeRef(t, ctx);
}
AddToCache(t, result, ctx);
return result;
}
示例9: GetBaseClasses
protected virtual IQueryable<ObjectClass> GetBaseClasses(IZetboxContext ctx)
{
var qry = ctx.GetQuery<ObjectClass>().Where(cls => cls.BaseObjectClass == null);
if (IsFallback)
qry = qry.Where(i => Compiler.FallbackModules.Contains(i.Module.Name));
return qry;
}
示例10: GetValueTypeProperties
protected virtual IQueryable<ValueTypeProperty> GetValueTypeProperties(IZetboxContext ctx)
{
var qry = ctx.GetQuery<ValueTypeProperty>();
if (IsFallback)
qry = qry.Where(i => Compiler.FallbackModules.Contains(i.Module.Name));
return qry;
}
示例11: GetRelationsWithSeparateStorage
protected virtual IEnumerable<Relation> GetRelationsWithSeparateStorage(IZetboxContext ctx)
{
var qry = ctx.GetQuery<Relation>()
.Where(r => r.Storage == StorageType.Separate);
if (IsFallback)
qry = qry.Where(i => Compiler.FallbackModules.Contains(i.Module.Name));
return qry
.ToList()
.OrderBy(r => r.GetAssociationName());
}
示例12: GetUser
private Identity GetUser(IZetboxContext ctx, int userid)
{
return ctx.GetQuery<Identity>().First(i => i.ID == userid);
}
示例13: SetUp
public override void SetUp()
{
base.SetUp();
ctx = GetContext();
obj = ctx.Create<Assembly>();
obj.Name = "TestAssembly";
obj.Module = ctx.GetQuery<Module>().First(m => m.Name == "TestModule");
}
示例14: ToRefOrDefault
/// <summary>
/// returns a zetbox Assembly for a given CLR-Assembly or null if it is not stored
/// </summary>
public static Assembly ToRefOrDefault(this System.Reflection.Assembly ass, IZetboxContext ctx)
{
if (ass == null) { throw new ArgumentNullException("ass"); }
if (ctx == null) { throw new ArgumentNullException("ctx"); }
// ToList: Workaround Case 1212
return ctx.GetQuery<Assembly>().ToList().SingleOrDefault(a => a.Name == ass.FullName);
}
示例15: CreateViewDescriptors
private static void CreateViewDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
{
using (Logging.Log.InfoTraceMethodCallFormat("CreateViewDescriptors", "Creating ViewDescriptors"))
{
var liveDescriptors = new HashSet<ViewDescriptor>();
foreach (var type in GetTypes(srAssembly))
{
object attr;
Toolkit? tk = null;
// http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
if (type.Assembly.ReflectionOnly)
{
attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewDescriptorAttribute).FullName);
if (attr != null) tk = (Toolkit)((SR.CustomAttributeData)attr).ConstructorArguments.Single().Value;
}
else
{
attr = type.GetCustomAttributes(typeof(ViewDescriptorAttribute), false).FirstOrDefault() as ViewDescriptorAttribute;
if (attr != null) tk = ((ViewDescriptorAttribute)attr).Toolkit;
}
if (attr != null)
{
var typeName = type.GetSimpleName();
// if a view can be used under multiple ControlKinds, it needs to have multiple ViewDescriptors
var descrList = ctx.GetQuery<ViewDescriptor>().Where(i => i.ControlTypeRef == typeName).ToList();
if (descrList.Count == 0)
{
var descr = ctx.Create<ViewDescriptor>();
descr.ControlTypeRef = typeName;
if (tk != null) descr.Toolkit = tk.Value;
liveDescriptors.Add(descr);
}
else
{
foreach (var descr in descrList)
{
descr.Deleted = false;
liveDescriptors.Add(descr);
}
}
}
}
var simpleAssemblyName = srAssembly.GetSimpleName();
var deadDescriptors = ctx
.GetQuery<ViewDescriptor>()
.ToList()
.Where(vmd => TypeSpec.Parse(vmd.ControlTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
.Except(liveDescriptors);
foreach (var d in deadDescriptors)
{
d.Deleted = true;
}
}
}