private static object GetRelacao(this IAbstractDataContext context, Type type, RelacaoAttribute relacao, bool inRelacao, TipoDatabase tipoDatabase) { if (relacao == null) { return(null); } var campos = RelacaoCampos.GetRelacaoCampos(relacao.Campos); var wheres = new List <string>(); foreach (var campo in campos) { var value = relacao.OwnerObj.GetInstancePropOrField(campo.AtributoRel); wheres.Add($"{campo.Atributo} = {tipoDatabase.GetValueStr(value)}"); } if (type is IList) { return(context.GetLista(type, string.Join(" and ", wheres), inRelacao)); } else if (type is object) { return(context.GetObjeto(type, string.Join(" and ", wheres))); } return(null); }
private static void RemRelacao(this IAbstractDataContext context, object obj, RelacaoAttribute relacao, bool inRelacao) { if (relacao == null) { return; } if (obj is IList) { context.RemLista(obj as IList, inRelacao); } else if (obj is object) { context.RemObjeto(obj as object); } }
private static RelacaoAttribute GetClone(this RelacaoAttribute relacao, Type ownerType = null, PropertyInfo ownerProp = null, object ownerObj = null) { return(new RelacaoAttribute(relacao.Campos, relacao.Tipo, ownerType, ownerProp, ownerObj)); }