Need help in retrieve query

Feb 3, 2011 at 10:58 AM

Hi,

how to write the own query in azure storage ?

Forexample :

In Table i have tid field.

If i want to retrieve the particular tid field without help or Rowkey. is it possible ?

In SQL Query like

select * from TableName where tid='data'

Please any one give me good suggestion for this problem ?

Thanks

Tamilmani Mohan

Feb 9, 2011 at 10:53 AM
Hi,

e.g. var x = from a in TableName where a.tid ='data' select a;

This will return you the required row.

I think, you can access this without using Row Key.

Your context class will be like that which needs to be inherited from TableServiceContext class
public class TestContext : TableServiceContext
{
public TestContext (string baseAddress, StorageCredentials credentials)
: base(baseAddress, credentials)
{
}
public IQueryable<TestEntity> GetData
{
get
{
return this.CreateQuery<TestEntity>("<Name of your storage Table>");
}
}
}
You need to define the entities of your Azure table by creating one entity class which needs to be inherited from TableServiceEntity class
public class TestEntity: TableServiceEntity
{
public TestEntity()
{
RowKey = string.Format("{0:10}_{1}",
DateTime.MaxValue.Ticks - DateTime.Now.Ticks,
Guid.NewGuid());
}
public Int32 Tid { get; set; }
public String Message { get; set; }
}


public class TestGetData
{
private static TestContext Credential()
{
var account = CloudStorageAccount.FromConfigurationSetting("BlobConn");
var dataContext = new TestContext(account.TableEndpoint.ToString(), account.Credentials);
return dataContext;
}
public List<TestEntity> ViewData(int Tid)
{
List<TestEntity> companylogList = new List<TestEntity>();
var context = Credential();
companylogList = (from r in dataContext.GetData
where r.Tid == Tid
select r).ToList<TestEntity>();
}
}
}

Try it out. If i did not able to resolve your query, then let me know. If you need any more help from me.

Regards,
Chiranjibi Das


From: [email removed]
To: [email removed]
Date: Thu, 3 Feb 2011 02:58:59 -0800
Subject: Need help in retrieve query [PHPAzure:244470]

From: Tamilmani
Hi,
how to write the own query in azure storage ?
Forexample :
In Table i have tid field.
If i want to retrieve the particular tid field without help or Rowkey. is it possible ?
In SQL Query like
select * from TableName where tid='data'
Please any one give me good suggestion for this problem ?
Thanks
Tamilmani Mohan
Read the full discussion online.
To add a post to this discussion, reply to this email (PHPAzure@discussions.codeplex.com)
To start a new discussion for this project, email PHPAzure@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com