This is a migrated thread and some comments may be shown as answers.

Several issues - DateTimeOffset, Module, Sort, Generic binding

15 Answers 259 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam
Top achievements
Rank 1
Adam asked on 31 Jul 2009, 12:40 PM
Bear in mind I am a newbie...

1) I have a SQL Server 2008 database with a table that has a DateTimeOffset. It is mapping it to a string, which causes an exception. What can I do? I have not tried HierarchyID, DateTime2, Geography, Geometry but I suspect there will be the same/similar problems.

2) I have a table called Module. For some reason it is being mapped to a class called Module1. All other tables do not get a "1" suffix. What is happening here?

3) The tables have columns in an order such as: ID, Name, Description. The RadGridView seems to default the columns in alphabetical order (Description, ID, Name). Any way to set it to the Ordinal position from the database?

4) I am trying to create a CRUD form for a subset of tables. Suppose (using Northwind, of course :-) that I want to have a combobox with the table names of Customers, Orders, and Products (only). When the user selects Customers, I would like to create a CRUD form (dynamically) that pulls in that table to edit, without having to specify .Extent<Customer>

Is there a way to get the table object by name, something like:
string tableName = myCombo.SelectedItem
crudWPF.DataContext =somefunction(tableName) // "Customer" would return the customer object, "Products" return <Product>, etc.
crudWPF.Show();

5) Is there any way to generate the CRUD form for WPF and not WinForms?

6)  Warning    1    OpenAccess Warning: Explicit change tracking required for the array field BillysORM.Picture.pictureData. [class=BillysORM.Picture] [field=pictureData]   

What does this mean and what do I need to do?

7) How does OpenAccess handle FileStream?


15 Answers, 1 is accepted

Sort by
0
Accepted
PetarP
Telerik team
answered on 05 Aug 2009, 11:20 AM
Hi Adam,

1. The problem comes from that currently Telerik OpenAccess ORM does not support the new data types introduced with SQL server 2008. This feature is scheduled for implementation for Q1 2010.
2. The word Module is a reserved word. That is why your table gets renamed with a number so that it differs from the reserved one. You can change that in the reverse mapping wizard before creating your classes. You can edit the name in the textbox that corresponds to the given class.
3. This pretty much depends on the way you bind your grid. If you are using a DataSource control you should not be experiencing any difficulties. Nevertheless you are able to easily rearrange the order by just reordering the binding columns in the grid definition.
4. You can construct dynamic SQL/OQL to be executed. Here is an example of constructing dynamic OQL query:
IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope(); 
            IQuery query = scope.GetOqlQuery("Select * from " + DropDownList1.SelectedValue.ToString() + "Extent where Name='sad'"); 
            var result = query.Execute(); 
            GridView1.DataSource = result.ToList(); 
            GridView1.DataBind(); 
5. Currently it is not possible but we are working on new dataform wizards as we speak.
6. The warning means that OpenAccess is not capable of tracking the changes made to an array field. If you change the whole array with another, the tracking will work, but if you change only one element of the array, it will not. So, to avoid this behavior, the field should be explicitly marked as "Dirty" when such operation occurs. You can use the ObjectScope.MakeDirty(object, fieldName) method to do this.
7. The type FileStream is currently unsupported.

Hope that my answers have shed some light over the work with Telerik OpenAccess ORM. If you have any further difficulties please do not hesitate to contact us.

Sincerely yours,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Adam
Top achievements
Rank 1
answered on 08 Aug 2009, 05:53 AM
How do I use ObjectScope.MakeDirty(object, fieldName)?

I was trying to do it in BeginEdit(), but no objects are passed.

Is there a way in the BeginEdit() to determine which object is being edited?

I tried TestViewModel.Scope.MakeDirty(this), but I need the 2nd argument.

Where does the Category.Editing.cs come from?
0
PetarP
Telerik team
answered on 11 Aug 2009, 02:09 PM
Hello Adam,

1. The ObjectScope.MakeDirty(object,fieldName) indeed requires two parameters.
persistentObject
The persistent object to be marked as dirty. It can also be an IEnumerable of objects to mark as dirty.
fieldName
The field of the persistent object to be marked as dirty.

Note that this method must be called before the editing occurs.
2. Can you please clarify to witch BeginEdit() method are you referring.

3. Usually Telerik OpenAccess ORM creates two partial classes. One holds the private fields of the class and it is named ($NameOfTheClass).Telerik.OpenAccess.cs. The other one holds the properties of the class and it is named ($NameOfTheClass).cs. Having this in mind we can exactly tell you from where this came from. Maybe you have created it somehow ? If you can provide us with the steps you took for this class to appear we will be more than happy to investigate further.

Regards,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Adam
Top achievements
Rank 1
answered on 11 Aug 2009, 03:57 PM
I got this from a sample your company sent.
All I am trying to do is drop a RadGrid on a form, bind the data and be able to edit/save it, marking it dirty, etc. If autogenerate columns is false, how would this be done? I read not to use DataMemberPath but use DataMemberBinding?


using System.ComponentModel; 
 
namespace NWOA 
    public partial class Category: IEditableObject  
    { 
        public void BeginEdit() 
        { 
            if (!TestViewModel.Scope.Transaction.IsActive) 
            { 
                TestViewModel.Scope.Transaction.Begin(); 
                 
            } 
        } 
 
        public void EndEdit() 
        { 
            TestViewModel.Scope.Transaction.Commit(); 
        } 
 
        public void CancelEdit() 
        { 
            TestViewModel.Scope.Transaction.Rollback(); 
        } 
    } 

using System.Collections.Generic; 
using Telerik.OpenAccess; 
using Telerik.OpenAccess.Query; 
 
namespace NWOA 
    public class TestViewModel 
    { 
        public static IObjectScope Scope = NWScopeProvider.GetNewObjectScope(); 
        public TestViewModel() 
        { 
            SetTable(); 
        } 
 
        public void SetTable() 
        { 
            var query = 
            from c in Scope.Extent<Category>() 
            select c; 
            CategoryList = query.ToList(); 
        } 
 
        public IList<Category> CategoryList 
        { 
            get; 
            set; 
        } 
 
        public Category SelectedItem 
        { 
            get; 
            set; 
        } 
 
    } 
}  
 

using System; 
using System.Windows; 
 
namespace NWOA 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    {  
        public Window1() 
        { 
            InitializeComponent(); 
            //this.radGridView1.CellEditEnded += new EventHandler<Telerik.Windows.Controls.GridViewCellEditEndedEventArgs>(radGridView1_CellEditEnded); 
        } 
 
        //void radGridView1_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e) 
        //{ 
             
        //} 
    } 
 
0
PetarP
Telerik team
answered on 14 Aug 2009, 06:57 AM
Hi Adam,

I am not exactly sure how are you achieving your binding but I am guessing that the objects bound in the grid are not tracked by any object scope. What you can do is when the editing has ended you will need to retrieve the edited object and cast it to the appropriate type. Since this object wont be tracked by our object scope a simple commit will not do the trick. You will need to retrieve the object that corresponds to the edited one from the database and modify its fields to match the ones you got from the grid. Than you can commit and the changes will be applied.

Best wishes,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Joseph Lam
Top achievements
Rank 1
answered on 19 Mar 2010, 03:02 PM
> "1. The problem comes from that currently Telerik OpenAccess ORM does not support the new data types introduced with SQL server 2008. This feature is scheduled for implementation for Q1 2010."

I'm trying out the 2010.1.312.2 release but it seems DateTimeOffset is still not supported. What's the revised schedule? Thanks.

Joseph
0
PetarP
Telerik team
answered on 23 Mar 2010, 06:17 PM
Hi Joseph Lam,

Yes you are correct. The support for the new data types did not make it in our Q1 release. However we are actively working on providing support for each of the missing data types. Unfortunately I cannot give you an exact time-frame in which we will have them ready but I will post here once we do.

Regards,
Petar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Stuart Miller
Top achievements
Rank 1
answered on 04 Jun 2010, 08:55 PM

Petar,

I'm evaluating OpenAccess ORM for our company, but I'm at a standstill because of the issue with the datetimeoffset sql server datatype. Should i just exclude this field for now, or is there are workaround or some sort of hack that you would suggest I try until the support can be added?  How have others been dealing with this?

Thanks,

Stuart

0
PetarP
Telerik team
answered on 07 Jun 2010, 12:49 PM
Hi Stuart Miller,

I am afraid I cannot offer you a workaround other than excluding the field from your model until the DateTimeOffset is supported. We are currently working on providing support for all sql server types and you should expect them with our Q2 release that is planned for mid of July.

Greetings,
Petar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Stuart Miller
Top achievements
Rank 1
answered on 30 Jul 2010, 02:36 PM
Petar,

Thanks for your response.  I updated to 2010 Q2, and it does appear that there has been some progress made regarding the Sql Server 2001 DateTimeOffset datatype.  I can see that the SqlType in the generated class property attribute correctly states "datetimeoffset", however, the CLR DataType for the property is string.  Not really sure if this is by intention or not.  However, when I try to extract data from the database, I get an Exception:

Telerik.OpenAccess.Exceptions.DataStoreException was unhandled
  Message=Error reading field File._created from ResultSet: System.InvalidCastException: Unable to cast object of type 'System.DateTimeOffset' to type 'System.String'.

If I manually change this to System.DateTime in the generated class property, I get this...

Telerik.OpenAccess.Exceptions.DataStoreException was unhandled
  Message=Error reading field File._created from ResultSet: Telerik.OpenAccess.RT.sql.SQLException: Conversion from System.DateTimeOffset to DateTime not supported.


Is the DateTimeOffset datatype still not supported?

Stuart
0
PetarP
Telerik team
answered on 30 Jul 2010, 04:14 PM
Hi Stuart Miller,

 Unfortunately covering all the available types proved to be more complex and time consuming than we  originally expected. This inevitably led to postponing of this feature for one of our next service packs.
I am terribly sorry for the inconvenience this might be causing.

Best wishes,
Petar
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 22 Dec 2010, 09:21 AM
Is there support for DateTimeOffset it 2010 Q3? If not - is there any firm date when you can add support of this valuable datatype to ORM. We very like your ORM, but DateTimeOffset is so useful in global web application, when you need to store dates in multiple timezones.
Thanks
0
PetarP
Telerik team
answered on 23 Dec 2010, 03:55 PM
Hello Adam,

 We have provided support for DateTimeOffset with our newest Q3 release. You should be able to use the DateTimeOffset type out of the box without any problems.

Best wishes,
Petar
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Clifton
Top achievements
Rank 1
answered on 03 Feb 2012, 03:22 AM
Hello Petar,
Recently trying out the Update Database from Model (of which has many DateTimeOffset fields and I keep getting an error indicating

"The metadata for fild 'blaa' of class 'blaaClass' cannot be initialized: No database type mapping found for field 'blaa':CLR type 'System.Nullable'1[[System.DateTimeOffset, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken = b77a5c561934e089]]' or column type unmapped."

Any thoughts on this feature? Will the datetimeoffset only work on reading a DB or should it work on writing one too.

Thanks

Clifton

0
Ady
Telerik team
answered on 07 Feb 2012, 06:50 PM
Hi Clifton,

 DateTimeOffset fields work while reading and writing to the database. What is not working is the UI to actually udpdate the table with 'datetimeoffset' columns. You can follow the below mentioned steps to get this to work
  1. I assume that your domain class is already mapped to a table, in the designer. Now, say you add a new property of type 'System.DateTimeOffset'. You should then use the 'Model Schema Explorer' (available via the View->Other windows->Entity Diagrams Schema Explorer menu) and select the table in the explorer. Right-click on it and select 'Edit table'
  2. Click 'Insert column' and add a new column with an appropriate name and sql type - datetimeoffset.
  3. Then you need to open the 'Mapping Details Editor' (available via the View->Other windows->Entity Diagrams Details Editor menu) and select the domain in the designer surface. Map the newly added property to the  newly added column
  4. Then use the 'Update Database from Model' and update the table in the database.

 We will work on getting this to work automatically so that you do not need add and map a column explicitly.

Do get back in case you need further assistance.


Regards,
Ady
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Databases and Data Types
Asked by
Adam
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Adam
Top achievements
Rank 1
Joseph Lam
Top achievements
Rank 1
Stuart Miller
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Clifton
Top achievements
Rank 1
Ady
Telerik team
Share this question
or