Esempio n. 1
0
 public IEnumerable <T> Load(DBLoadParam param = DBLoadParam.None)
 {
     using (var transaction = new DBTransaction(Table.Connection, null, true)
     {
         View = this
     })
     {
         return(table.Load(Query, param, transaction));
     }
 }
Esempio n. 2
0
        public DBTable <T> ExecuteTable <T>(string tableName, string query) where T : DBItem, new()
        {
            var schema = new DBSchema()
            {
                Name = "temp", Connection = this
            };
            var table = new DBTable <T>(tableName)
            {
                Schema = schema
            };

            using (var transaction = new DBTransaction(this, null, true))
            {
                table.Load(transaction.AddCommand(query));
            }
            return(table);
        }
Esempio n. 3
0
        public static async Task <Instance> GetByNetId(IPEndPoint endPoint, bool create, IUserIdentity user = null)
        {
            var query = new QQuery(DBTable);

            query.BuildPropertyParam(nameof(Host), CompareType.Equal, endPoint.Address.ToString());
            query.BuildPropertyParam(nameof(Port), CompareType.Equal, endPoint.Port);
            query.BuildPropertyParam(nameof(Action), CompareType.Equal, false);
            var instance = DBTable.Load(query).LastOrDefault();

            if (instance == null && create)
            {
                instance = new Instance
                {
                    EndPoint  = endPoint,
                    Active    = true,
                    IsCurrent = true
                };
                await instance.Save(user);
            }
            return(instance);
        }