Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedDNN 7 Development DAL2 helpDNN 7 Development DAL2 help
Previous
 
Next
New Post
12/25/2012 10:18 AM
 

Hi,i'm studying last dnn innovations and dal2.

I read some blog posts from dnn experts on this argument, but i can't find other documentation on this, so I hope someone can help me here.

I've an info class like this:

    [TableName("mwOfficies")]
    [PrimaryKey("OfficeID")]
    [Scope("ModuleID")]
    [Cacheable("Offices", CacheItemPriority.Default, 20)]
    public class OfficeInfo
    {

        public int OfficeID { get; set; }
        public int ModuleID { get; set; }
        public string Name { get; set; }
        public int OfficeTypeID { get; set; }               //Linked table    
        [IgnoreColumn]
        public string OfficeEmail { get; set; }
        public DateTime OfficeOpened { get; set; }
}

 

Created a Controller class to get data:

public static IEnumerable<OfficeInfo> GetCurrentOffices(int moduleId, int status)
        {

            IEnumerable<OfficeInfo> offices;

            using (IDataContext context = DataContext.Instance())
            {
                var repository = context.GetRepository<OfficeInfo>();
                offices = repository.Find("WHERE ModuleID = @0 " +
                    "AND (FK_STATO < @1)", moduleId, status);
            }
            return offices;
        }

now I've those questions:

1) in dnngrid I used MyController.GetCurrentOffices(ModuleID, 3) as dnngrid datasource, but i can see only 20 results as dnngrid.pagesize = 20, but no pager is displayed

 2) I've a Linked column (you can see the property OfficeTypeID) on a Type SQL table where i need to map Office.TypeID = Types.ID and get the OfficeType name to display on dnngrid. How i can do this on DAL2?

the announcements module source code isn't a good start, it has only one table :(

 
New Post
1/9/2013 7:51 AM
 
1) solved, rewriting dnnGrid attributes now I can see paging properly.

For second issune anyone can give me an advice?
 
New Post
1/30/2013 12:55 PM
 
You have 2 options:

Option 1:
  1. Add a templatecolumn with, for example, an asp:Label in it, to the dnngrid's definition.
  2. Then, add an OnItemDataBound-method to your codebehind, for the dnngrid.
  3. In the method, retrieve the correct Type from Types, using the repository.GetById functionality combined with the OfficeTypeID-property's value, and set the label's text from the resulting Type-object.
Option 2:
  1. Create a View in your database, that does an inner join to your Types-table and returns (amongst all the Office-properties), an extra column named (for example) "OfficeTypeName".
  2. Create an additional String-property in your OfficeInfo-class with the exact same name (thus, following my own example, "OfficeTypeName").
  3. A. Alter the "TableName"-attribute of your OfficeInfo-class to contain the new view's name. I'm not completely sure whether or not that will work, but since MSSQL itself treats views as tables, I'm expecting DAL2/PetaPoco to do so too.
    B
    . If A doesn't work, then alter your GetCurrentOffices to use context.ExecuteQuery([params]).
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedDNN 7 Development DAL2 helpDNN 7 Development DAL2 help


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out