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])); }
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)); }
public static object[] GetKey(this EntityObjectStore.LocalContext context, INakedObject nakedObject) { return(context.GetIdMembers(nakedObject.GetDomainObject().GetEntityProxiedType()).Select(x => x.GetValue(nakedObject.GetDomainObject(), null)).ToArray()); }
public static PropertyInfo[] GetNonIdMembers(this EntityObjectStore.LocalContext context, Type type) { return(context.GetMembers(type).Where(x => !context.GetIdMembers(type).Contains(x)).ToArray()); }
public static object[] GetKey(this EntityObjectStore.LocalContext context, object domainObject) => context.GetIdMembers(domainObject.GetEntityProxiedType()).Select(x => x.GetValue(domainObject, null)).ToArray();