Massive.DynamicModel.All C# (CSharp) Method

All() public method

Returns all records complying with the passed-in WHERE clause and arguments, ordered as specified, limited (TOP) by limit.
public All ( string where = "", string orderBy = "", int limit, string columns = "*" ) : IEnumerable
where string
orderBy string
limit int
columns string
return IEnumerable
        public virtual IEnumerable<dynamic> All(string where = "", string orderBy = "", int limit = 0, string columns = "*", params object[] args)
        {
            string sql = BuildSelect(where, orderBy, limit);
            return Query(string.Format(sql, columns, TableName), args);
        }

Usage Example

        public static void ScrapeChannels(object args)
        {
            if (Interlocked.CompareExchange(ref Running, 1, 0) != 0)
                return;

            try
            {
                if (String.IsNullOrEmpty(downloadDir))
                {
                    string dir = ConfigurationManager.AppSettings["torrentsdir"];
                    if (!String.IsNullOrEmpty(dir))
                    {
                        var context = args as HttpContextBase;
                        if (Path.IsPathRooted(dir) == false && context != null)
                            dir = context.Server.MapPath(dir);

                        if (Directory.Exists(dir))
                            downloadDir = dir;
                        else
                            downloadDir = Environment.CurrentDirectory;
                    }
                }

                var table = new DynamicModel("LDSTorrents", tableName: "Channels", primaryKeyField: "ChannelID");

                var channels = table.All();
                foreach (var channel in channels)
                {
                    try
                    {
                        logger.InfoFormat("Scraping '{0}'...", channel.Title);
                        var videos = ScrapeChannel(channel);
                        Torrents.Save(videos.ToArray());
                        table.Update(new { LastUpdated = DateTime.Now }, channel.ChannelID);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(String.Format("Failed to scrape channel '{0}' with the following exception: ", channel.Title), ex);
                        ErrorLog.GetDefault(null).Log(new Error(ex));
                    }
            #if DEBUG
                    break;
            #endif
                }
            }
            catch (Exception ex)
            {
                logger.Error("ScrapeChannels failed with the following exception: ", ex);
                ErrorLog.GetDefault(null).Log(new Error(ex));
            }

            Interlocked.Exchange(ref Running, 0);
        }
All Usage Examples Of Massive.DynamicModel::All