locked
CustomFieldDefinition in Simpleprovider RRS feed

  • Question

  • Hi i have a question,

     

    i dont understand the Customfields in Simpleprovider.

    I implement one is this way and it works:

    Code Snippet

     

    public override ItemMetadataSchema MetadataSchema
            {
                get
                {
                    CustomFieldDefinition[] customFields = new CustomFieldDefinition[1];
                    customFields[0] = new CustomFieldDefinition(1, typeof(ulong));

                    IdentityRule[] identityRule = new IdentityRule[1];
                    identityRule[0] = new IdentityRule(new uint[] { 1 });

                    return new ItemMetadataSchema(customFields, identityRule);
                }
            }

     

     

    But i want du use strings as identifyer, in this way :

    Code Snippet

    public override ItemMetadataSchema MetadataSchema
            {
                get
                {
                    CustomFieldDefinition[] customFields = new CustomFieldDefinition[1];
                    customFields[0] = new CustomFieldDefinition(1, typeof(string));

                    IdentityRule[] identityRule = new IdentityRule[1];
                    identityRule[0] = new IdentityRule(new uint[] { 1 });

                    return new ItemMetadataSchema(customFields, identityRule);
                }
            }

     

     

    but it dosent work, i get an exception "out of range". Is it possible to use string at this place and if yes HOW!!!??! Sad


    p.s. sorry for my bad english, im from germany. Smile

    Friday, November 7, 2008 4:01 PM

Answers

  • Hi Steffen

     

    Yes, you can use CustomFieldDefinition with fieldType == typeof(string).  In order to use it with string you need to use the second constructor for the class. 

     

    public override ItemMetadataSchema MetadataSchema
    {

    get
    {

    CustomFieldDefinition[] customFields = new CustomFieldDefinition[1];

    customFields[0] = new CustomFieldDefinition(1, typeof(string), fieldSize);

    IdentityRule[] identityRule = new IdentityRule[1];
    identityRule[0] = new IdentityRule(new uint[] { 1 });

    return new ItemMetadataSchema(customFields, identityRule);

    }

    }

     

    where uint fieldSize is the size associated with the field.

     

    You will need to use the second constructor for the following types: string and byte[].

     

    Maria del Mar Alvarez Rohena - MSFT

    Monday, November 10, 2008 6:25 PM
  • Hi Steffen

     

    I believe your problem is in the way you are constructing the ItemField.  Your CustomFieldDefinition says that your field is of type string, but you are passing an ItemFiled of type ulong.

     

    Code Snippet

     

    ItemFieldDictionary dir = new ItemFieldDictionary();
                    dir.Add(new ItemField(1, typeof(ulong), item.Name));
                  

     

     

    I would change the above code to:

     

    Code Snippet

     

    ItemFieldDictionary dir = new ItemFieldDictionary();
                    dir.Add(new ItemField(1, typeof(string), item.Name));
                  

     

     

     

    And yes, the fieldSize corresponds to the max number if bytes in your string field.

     

    Maria del Mar Alvarez Rohena - MSFT

    Tuesday, November 11, 2008 6:04 PM
  • Yes you are right, with MSF v2 CTP1 does not support custom metadata stores, but we are considering adding this support for the next release.

     

    Can you tell us a little more about your scenario, and how a custom metadata store would be preferred?


    Maria del Mar Alvarez Rohena - MSFT

    Thursday, November 13, 2008 1:20 AM

All replies

  • Hi Steffen

     

    Yes, you can use CustomFieldDefinition with fieldType == typeof(string).  In order to use it with string you need to use the second constructor for the class. 

     

    public override ItemMetadataSchema MetadataSchema
    {

    get
    {

    CustomFieldDefinition[] customFields = new CustomFieldDefinition[1];

    customFields[0] = new CustomFieldDefinition(1, typeof(string), fieldSize);

    IdentityRule[] identityRule = new IdentityRule[1];
    identityRule[0] = new IdentityRule(new uint[] { 1 });

    return new ItemMetadataSchema(customFields, identityRule);

    }

    }

     

    where uint fieldSize is the size associated with the field.

     

    You will need to use the second constructor for the following types: string and byte[].

     

    Maria del Mar Alvarez Rohena - MSFT

    Monday, November 10, 2008 6:25 PM
  • hi,

     

    at first thanks.
    But one question still leaves. What defined the ulong "fieldsize"? The size in byte of the string?

     

    because when i do this:

    Code Snippet

    public override ItemMetadataSchema MetadataSchema
            {
                get
                {
                    CustomFieldDefinition[] customFields = new CustomFieldDefinition[1];
                    customFields[0] = new CustomFieldDefinition(1, typeof(string), 10000);
                   
                  
                    IdentityRule[] identityRule = new IdentityRule[1];
                    identityRule[0] = new IdentityRule(new uint[] { 1 });

                    return new ItemMetadataSchema(customFields, identityRule);
                }
            }

     

     

    and than fill the field with a 4 chars long string:

    Code Snippet

     

    ItemFieldDictionary dir = new ItemFieldDictionary();
                    dir.Add(new ItemField(1, typeof(ulong), item.Name));
                  

     

     

    i get always a "Argument out of range" exeption in the setting part.

    Tuesday, November 11, 2008 4:15 PM
  • Hi Steffen

     

    I believe your problem is in the way you are constructing the ItemField.  Your CustomFieldDefinition says that your field is of type string, but you are passing an ItemFiled of type ulong.

     

    Code Snippet

     

    ItemFieldDictionary dir = new ItemFieldDictionary();
                    dir.Add(new ItemField(1, typeof(ulong), item.Name));
                  

     

     

    I would change the above code to:

     

    Code Snippet

     

    ItemFieldDictionary dir = new ItemFieldDictionary();
                    dir.Add(new ItemField(1, typeof(string), item.Name));
                  

     

     

     

    And yes, the fieldSize corresponds to the max number if bytes in your string field.

     

    Maria del Mar Alvarez Rohena - MSFT

    Tuesday, November 11, 2008 6:04 PM
  •  

    oh  my false. i try it tomorrow. im at home now ^^ thx so long
    Tuesday, November 11, 2008 6:19 PM
  • yes it works, thanks a lot.

     

    one question, in the CTP you can only use the sqlMetaDataStore for simpleProvider, right? Will custom MetaDataStore's be avalible in the next version and when next version is coming?

    Wednesday, November 12, 2008 8:28 AM
  • Yes you are right, with MSF v2 CTP1 does not support custom metadata stores, but we are considering adding this support for the next release.

     

    Can you tell us a little more about your scenario, and how a custom metadata store would be preferred?


    Maria del Mar Alvarez Rohena - MSFT

    Thursday, November 13, 2008 1:20 AM
  • In my Application is one part a mobile Device management and one part from this is a file Sync from PC to PPC.

    For each Device you can build sync jobs with a source and a destination folder. I use the Simple Provider for this. And i dont want to save the Metadatas on lokal harddisk or device. i want to save it in the syncJob. I hope you understand my explaination. I not so good in english

     

    Thursday, November 13, 2008 9:42 AM
  • I see, if I am understanding correctly, you want to save your metadata in memory.  Am I correct?

    Maria
    Thursday, November 13, 2008 6:03 PM
  • yes correctly

    Thursday, November 13, 2008 6:06 PM
  • is there a release date (circa) for next release?

     

    Monday, November 17, 2008 4:55 PM
  • For news on Microsoft Sync Framework Releases you can monitor our MSDN Developer site at: http://msdn.microsoft.com/en-us/sync/default.aspx

     

    Or subscribe to our news feed at: http://services.community.microsoft.com/feeds/feed/sync

     

    Maria del Mar Alvarez Rohena - MSFT

    Monday, November 17, 2008 10:25 PM
  • Hi Steffen,

     

    At least during the sync session, the metadata store must be on the local disk. It's up to you where you keep the file before and after the sync - you can transfer it to a mobile device, share, etc. We may add some additional features to address this in the future, but right now there's no easy way to store metadata only in memory if you're using simple sync providers. You can do it with knowledge sync providers, which are more flexible but require more work to get off the ground. I don't really know much about your specific scenario - if you give us more details we may be able to suggest something.

     

    Lukasz [MSF dev]

    Tuesday, November 18, 2008 8:16 PM