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);
        }
        //-- objeto

        public static TObject GetObjeto <TObject>(this IAbstractDataContext context, object filtro = null, bool relacao = true)
        {
            var listaDeCampoTipo = new[] { CampoTipo.Key };

            var where = context.GetComando()
                        .ComObjeto(filtro)
                        .ComTipoCampo(listaDeCampoTipo)
                        .GetWhereObj();
            return((TObject)context.GetObjeto(typeof(TObject), where, relacao));
        }
Beispiel #3
0
 public TObject GetById(TObject objeto) =>
 (TObject)_dataContext.GetObjeto(typeof(TObject), objeto);
Beispiel #4
0
 internal object ExecuteInstance(string where)
 {
     return(_dataContext.GetObjeto(typeof(TInstance), where));
 }