示例#1
0
        public static object GetNextKey(this EntityObjectStore.LocalContext context, Type type)
        {
            PropertyInfo idMember = context.GetIdMembers(type).Single();
            string       query    = string.Format("max(it.{0}) + 1", idMember.Name);

            dynamic os = context.GetObjectSet(type);
            ObjectQuery <DbDataRecord> results = os.Select(query);
            DbDataRecord result = results.Single();

            return(GetNextKey(type, result.IsDBNull(0) ? 1 : (int)result[0]));
        }
示例#2
0
        public static object ProxyObject(this EntityObjectStore.LocalContext context, object objectToProxy)
        {
            if (TypeUtils.IsProxy(objectToProxy.GetType()))
            {
                return(objectToProxy);
            }

            object newObject = context.GetObjectSet(objectToProxy.GetType()).CreateObject();

            PropertyInfo[] idMembers = context.GetIdMembers(objectToProxy.GetType());

            idMembers.ForEach(pi => newObject.GetType().GetProperty(pi.Name).SetValue(newObject, pi.GetValue(objectToProxy, null), null));

            return(context.GetObjectSet(objectToProxy.GetType()).ApplyCurrentValues((dynamic)newObject));
        }
示例#3
0
 public static object[] GetKey(this EntityObjectStore.LocalContext context, INakedObject nakedObject)
 {
     return(context.GetIdMembers(nakedObject.GetDomainObject().GetEntityProxiedType()).Select(x => x.GetValue(nakedObject.GetDomainObject(), null)).ToArray());
 }
示例#4
0
 public static PropertyInfo[] GetNonIdMembers(this EntityObjectStore.LocalContext context, Type type)
 {
     return(context.GetMembers(type).Where(x => !context.GetIdMembers(type).Contains(x)).ToArray());
 }
示例#5
0
 public static object[] GetKey(this EntityObjectStore.LocalContext context, object domainObject) => context.GetIdMembers(domainObject.GetEntityProxiedType()).Select(x => x.GetValue(domainObject, null)).ToArray();